in reply to how to overcome Win32 path delimiter in s///?
Wrap $path in \Q and \E (which escapes metachars) like so...
my $file = 'c:\some\win32\path\mydir\file.txt'; my $path = 'c:\some\win32\path'; (my $file_nopath_noext = $file) =~ s/\Q$path\E\\(.*)\.txt/$1/; print $file_nopath_noext."\n";
See perldoc perlre.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to overcome Win32 path delimiter in s///?
by bsdz (Friar) on Oct 14, 2004 at 23:41 UTC | |
by inman (Curate) on Oct 15, 2004 at 09:25 UTC |