One relatively simple way to accomplish this would be to use subrefs with the 'e' switch (though I'd still use a parser instead):
#!/usr/bin/perl -w use strict; my $foo = sub { "$1 years ago" }; my $bar = 'Four score and perhaps seven'; $bar =~ s/perhaps (seven)/&$foo/e; print $bar;
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In reply to Re: Drop in regex replacements?
by Ovid
in thread Drop in regex replacements?
by IOrdy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |