Absolutely nothing should be done with Perl, it is 2023.
If you're jonesing for a sed replacement (it even has capture groups) try: https://github.com/chmln/sd
Worth being aware of:
Nice tool but the name is a bit unfortunate:
https://github.com/chmln/sd (a modern sed alternative)