in reply to improve performance
I suspect that your use of $strfile in a regex may not be the best way to go about it, since it would make more sense if you were looking for exact matches, e.g. grep {$_ eq $strfile} @arraytocompare
If you know the filenames are unique (usually a fairly safe bet), you can use a hash instead of @arraytocompare, or convert it to one with something like my %tocompare = map {$_=>1} @arraytocompare;, and then test against that via if (!$tocompare{$strfile}) ....
|
|---|