in reply to Re: How do I pass $1 to s///?
in thread How do I pass $1 to s///?
...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"});
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do I pass $1 to s///?
by ikegami (Patriarch) on Jan 06, 2006 at 19:32 UTC | |
by Anonymous Monk on Jan 06, 2006 at 20:10 UTC | |
by ikegami (Patriarch) on Jan 06, 2006 at 20:17 UTC | |
by Anonymous Monk on Jan 06, 2006 at 21:03 UTC | |
by ikegami (Patriarch) on Jan 06, 2006 at 21:10 UTC |