...or...sub foo { (my $text = $_[0]) =~ s/$_[1]/$_[2]->($1)/e; print $text; } foo("This is test 1\n", qr/test (.*)/, sub{"fish $_[0]"});
sub foo { (my $text = $_[0]) =~ s/$_[1]/$_[2]->()/e; print $text; } foo("This is test 1\n", qr/test (.*)/, sub{"fish $1"});
In reply to Re^2: How do I pass $1 to s///?
by Anonymous Monk
in thread How do I pass $1 to s///?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |