in reply to Re: Regular Expression Loop Hell
in thread Regular Expression Loop Hell

Run this code and you'll see exactly why that code is not helpful. It's not about the regex, it's about the double loop.

#!/usr/bin/perl -w 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); $i = 0; while($i < 5) { foreach $anm (@animals) { $anm =~ s/$_/$hs{$_}/g, for(keys %hs); print "$anm"; } shift(@changeTo); push(@changeTo, int(rand(10000))); @hs{@toFind} = (@changeTo); print "\n"; print "@changeTo"; $i++; print "\n\n"; }