in reply to Re: Storing Regular Expressions as Strings in Array??
in thread Storing Regular Expressions as Strings in Array??
I had to make the following change to the above snippet to be able to make it work as intended... i.e. the $string ends up as "bar zaz".
my @subs; push @subs,sub{local $_=shift; s/foo/bar/g; $_}; push @subs,sub{local $_=shift; s/baz/zaz/g; $_}; my $string="foo baz"; $string = $_->($string) foreach @subs; # *** CHANGED *** # print $string;
Thanks for the code though, it was very helpful
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Code Correction
by demerphq (Chancellor) on May 03, 2002 at 08:26 UTC |