in reply to regex expression help

For the input you gave, it won't make a difference, but if $Y is a constant string, not a regexp, you should escape it, as follows:

foreach $Y (@dependantFiles) { foreach $X (@namedFiles) { if( $X =~ m/\Q$Y\E/i) { print "Found it\n" last; } } }

I also removed the useless 'g' option and the useless 'next'.

But if it's not a regexp, why use m// at all! index is much faster:

foreach $Y (@dependantFiles) { foreach $X (@namedFiles) { if (index(lc($X), lc($Y)) >= 0) { print "Found it\n" last; } } }

With a slight optimization:

foreach $Y (@dependantFiles) { my $lcY = lc($Y); foreach $X (@namedFiles) { if (index(lc($X), $lcY) >= 0) { print "Found it\n" last; } } }

If the $Y will always be at the end of $X, the following is even faster and more accurate:

foreach $Y (@dependantFiles) { my $lcY = lc($Y); foreach $X (@namedFiles) { if (lc(substr($X, -length($Y))) eq $lcY) { print "Found it\n" last; } } }

I haven't solved the problem where $X is c:\path\ab.exe and $Y is b.exe. There are a couple of solutions, but I'll let you try to solve it before I say more.