in reply to perl code in regex replacement

Assuming (dangerous) that I've interpreted your problem statement as you intended, one way of doing the job (in the problem you specified; adding 10 to a 3 digit decimal value) and without resort to executing code inside a regex is:

#/usr/bin/perl use strict; use warnings; # 892837 my $x = 123; # no quotes my $y = $x; $y =~ /(\d{2})(\d)/; # regex, but see also perlretut re executing c +ode in a regex $y = ($1+1).$2; print $y;