in reply to Regular Expression Loop Hell
my @animals = ( "bear<1>\n", "camel<0> <2>\n", "<2>horse\n", "duck<3>\ +n" ); my @changeTo = ( 'A', 'B', 'C', 'D' ); my @toFind = ( '<0>', '<1>', '<2>', '<3>' ); @hs{@toFind}= (@changeTo); foreach $anm (@animals) { $anm =~ s/$_/$hs{$_}/g, for(keys %hs); print "$anm"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular Expression Loop Hell
by pjnet (Novice) on Mar 08, 2006 at 17:31 UTC |