You are probably familiar with the power of regexes and substitution in Perl, but there are many rarely needed, but incredible features you might not know yet.

A simple example of something you are probably familiar with looks like this:

examples/regex/subst.pl

use 5.010;
use strict;
use warnings;

my $str = "abc 24 def";

$str =~ s/(\d)(\d)/$2$1/;

say $str;   # abc 42 def

Here we capture two digits in the original string and swap them.

That's nice, but what if we would like to replace the two digits by their sum?