in reply to Matching C-Style comments

Instead of storing the text in an array just store it in a string and then you can use a regular regexp:

#!/bin/perl -w use strict; undef $/; # so <DATA> will slurp the entire file my $string=<DATA>; $string=~ s{/\*.*?\*/}{}gsx; # do not forget the s modifier so . matc +hes \n too print $string; __DATA__ A text /* with comments */, some even /* cross several lines */, some even /* cross many, many, many */ lines

Of course you can also "unroll the loop" as Brovnik mentionned