http://www.perlmonks.org?node_id=103573


in reply to How can I increment a var in a substitution?

the e modifier means evaluate right side of substitution as perl code... so you need /'<<TOKEN_'.$n++.'>>'/ to make it into perl code that makes the string you want to substitute... you could also do...
$html_file_slurped_to_a_scalar =~ s/<img .*?>/«TOKEN_${\($n++)}»/gis;
which is a little trick to put code into an interpolated string

                - Ant
                - Some of my best work - Fish Dinner