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
In reply to Code Correction
by arunhorne
in thread Storing Regular Expressions as Strings in Array??
by arunhorne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |