in reply to Drop in regex replacements?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Drop in regex replacements?
by IOrdy (Friar) on Sep 09, 2002 at 16:41 UTC |