$find="C:\\Dir1\\Dir2\\Dir3"; $replace=''; $var = "C:\\Dir1\\Dir2\\Dir3\\KeepMe"; $var =~ s/$find/$replace/eeg; print "\$var: $var\n";