in reply to A Quirk in File::Find?

my $directory = "\.\\v706_7-17"; # Set directory to search m|$directory\/(.*)| # Variable way that didn't work

So $directory contains the string .\v706_7-17. As a regex pattern, it matches a string that contains any character followed by a vertical whitespace (\v) followed by "706_7-17".

You forgot to convert your literal text into a regex pattern. You can use quotemeta to do this, most easily via \Q\E:

m|\Q$directory\E\/(.*)|

Note that you probably want a ^ at the start of that pattern.

Replies are listed 'Best First'.
Re^2: A Quirk in File::Find?
by Larson2042 (Novice) on Sep 23, 2009 at 21:42 UTC
    Ah, I think I see what's going on. Basically, what's in $directory is being interpolated twice in the pattern match. The first interpolation is going from $directory to .\v706_7-17 and then it's being interpolated again, so it's looking for a vertical tab and then 706_7-17. And the forwardslash worked because it isn't a metacharacter. Thanks. That quotemeta will be useful in the future. I'd never heard of it before.

      and then it's being interpolated again,

      No. Then the string resulting from the interpolation is used as a regex pattern.