I'm using a while loop to iterate over some text to find all the instances of a pattern match. When I do the substitution on the match, the process hangs (some how I've created an infinite loop?) I thought perhaps it was the "[]" characters in one of the variables that was causing problems on interpolation but escaping them didn't help. Is there a better way to substitute text on multiple matches when you need match specific substitutions?
while ($str =~ /<tag1[^>]*>\s*<tag2>\s*<tag3>([^<]*)<\/endtag3>/gsi) { ++$a; $b = $1; $b = $b . " [ $c-$a]"; $str =~ s/(<tag1[^>]*>\s*<tag2>\s*)<tag3>[^<]*<\/endtag3>/ +$1<tag3>$b<\/endtag3>/si; }
In reply to while loop w/match is hanging by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |