Do we have the equivalent of preg_callback in Perl?
Suppose I want to match something and replace it with the return value of a function called with the matching thing.
Use s///e - evaluation modifier, and you can put arbitrary Perl codes in the second part.
s///e
$x = "this is a test"; $x =~ s/(test)/reverse($1)/eg; print $x; //this is a tset
ref: http://perldoc.perl.org/perlretut.html#Search-and-replace