in reply to Re: Regexp - exact matches
in thread Regexp - exact matches

You appear to be printing out the final value of "$LookFor" as a confirmation/debugging message, prior to actually doing the search. So the big question is: what shows up as the value of "$LookFor"? Given the code and sample file names you've given us just now, the last bit we're missing is knowing the values of the various "$srch_XXX" strings -- maybe this can be guessed at if we know what shows up as the final value of "$LookFor", and it will be possible to work out why it's giving you results you don't want.

Apart from that, looking at what you have above, and assuming that "$srch_host" always has a literal-match string (like "box1", "box12", etc), then the part where you use "$LookFor" in a regex (not in your snippet) ought to work if you use it like this:

if( /^$LookFor$/ ) { # true if $_ contains a matching file name ... }