in reply to NT paths and regexp

The string is being interpolated again, so you need \ x4.
$filename_b = "c:\\\\abc.log";
but then the eq won't work.
You could also use the magic of qr//
$filename_a = "c:\\abc.log"; $filename_b = "c:\\abc.log"; $filename_b_re = qr/c:\\abc.log/; print "Are they equal ? : "; print $filename_a eq $filename_b ; # output is 1 print "\n"; print "Do they match ? : "; print $filename_a =~ /$filename_b_re/ ; # output is 1

Another option(prefered, at least by me) is to use / instead of \\
$filename_a = "c:/abc.log"; $filename_b = "c:/abc.log";

- Tom

Replies are listed 'Best First'.
Re: NT paths and regexp
by Abigail-II (Bishop) on Sep 12, 2003 at 14:47 UTC
    You could also use the magic of qr//

    But only if you cut-and-paste the string, not if you do:

    $filename_b_re = qr /$filename_b/;

    It's not the magic of qr that makes it work, it's the magic of cut-and-paste. This will work too:

    print $filename_a =~ /c:\\abc.log/; # output is 1

    Abigail

      I know, I was giving some options.
      Like i said, the way I prefer to do it is using c:/abc.log. NT sees it as a valid path, and you don't have to worry about escaping anything.

      - Tom