in reply to Call subroutines inside regexp, using backrefences as parameters

Sure, with the /e modifier: $str =~ s/_(.*?)_/test($1)/eg;

See perlop for details. Also note that $1 should be used instead of \1 in the substitution part of a regex.

Update: oops, missed the actual /e in the example - bellaire++

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: Call subroutines inside regexp, using backrefences as parameters
by Anonymous Monk on Mar 31, 2010 at 12:46 UTC
    Thank you!