use re debug; $ScriptPath = "\\\\SERVER\\C\$\\APP\\BIN"; $file = $ScriptPath."\\somefile.txt"; warn $file; warn $ScriptPath; $file =~ s|\Q$ScriptPath\E||; warn $file;