I'm trying to find a directory path in a file and can only get it to work with 3 back slashes.
sample file:
script to find the directory path named in the file:
Why do I need 3 back slashes in the $path variable? I would think 2 back slashes would do the trick but it doesn't work.
Thanks.
Denis
sample file:
Code:
this is a sample file line
here is C:\directory\match
another line
script to find the directory path named in the file:
Code:
$path = "C:\\\directory\\\match";
open IN, "samplefile" or die "failed" ;
undef $/;
$wholefile = (<IN>);
if ( $wholefile =~ /$path/ ) {
print "found it $path in file";
}
Why do I need 3 back slashes in the $path variable? I would think 2 back slashes would do the trick but it doesn't work.
Thanks.
Denis