in reply to Trying to determine if path exists in environmental variable
While the problem occurs in the if() clause the cause is the value of $newpath and the lack of a quotemeta which should be considered mandatory when interpolating a variable into the match side of a regex
my $newpath='C:\Perl\bin'; .... if ($path->[0] =~ /$newpath/ ) # perl sees this as ... =~/C:\Perl\bin/; # you need either to $newpath = quotmeta $newpath # or do it in the match =~/\Q$newpath/
With quotemeta your code runs as expected.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|