in reply to NT paths and regexp
That is because you wrote the wrong code:
print "Do they match ? : "; print $filename_a =~ /\Q$filename_b\E/ ; # output is 1
Always remember:
/$regex/ /\Q$string\E/
If you use a variable as part of a regex, Perl needs to know if you want to interpret that variable as a string or as a regex. The default is to interpret it as a regex. If you want to use a string (from a variable) in a regex, then you need to tell Perl that by using \Q (or quotemeta, though this is can't be used as easily directly in the regex).
- tye
|
|---|