Note that the overall structure of the script could be improved. It currently matches the same pattern three times:
while (<>) { if (/.../) { while (/.../) { s/.../.../; } print; } else { print; } } s///g already encompasses the function of the conditional and the inner loop, so those are redundant. There's a more idiomatic way to approach this: #!perl my $str = '##'; my $iter = 0; while (<>) { s/$str/++$iter/ge; print; } __END__ /e executes the substitution string as a block of Perl code, in this incrementing $iter and returning the result. Ronald -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.