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";