trout16 has asked for the wisdom of the Perl Monks concerning the following question:
my $path = "C:\\temp\\dest"; $path =~ s/C:\\temp//i; print "new path: $path\n";
But I need to use a variable, and this doesn't work (prints 'new path: C:\temp\dest'):
my $srcDir = "C:\\temp"; my $path = "C:\\temp\\dest"; $path =~ s/$srcDir//i; print "new path: $path\n";
And it dies on this line, but I don't know why (prints 'Died at sub.pl line 4.'):
$path =~ s/$srcDir//i or die;
Another example of a substitution using variables that does not work (prints 'Died at sub2.pl line 5.'):
my $srcDir = "C:\\temp"; my $destDir = "C:\\temp2"; my $path = "C:\\temp\\dest"; $path =~ s/$srcDir/$destDir/i or die; print "new path: $path\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Windows directory path variable binding operator substitutions
by moritz (Cardinal) on Mar 17, 2008 at 16:54 UTC | |
|
Re: Windows directory path variable binding operator substitutions
by kyle (Abbot) on Mar 17, 2008 at 16:55 UTC | |
|
Thank you
by trout16 (Novice) on Mar 17, 2008 at 17:18 UTC |