in reply to Susbstituting strings with escape characters.
You should have a look at perlop about interpolation: The backslash is a tricky character, especially in double quotes. If you had enabled warnings, the invalid escapes \c and \d would have occured to you already.
my $cache = q{\\\\myserver\cache\dir}; my $path = q{\\\\myserver\cache\dir\2003\Feb\file.tmp};
Inside q// (aka 'single quotes') the backslash only escapes itself and the string delimiter.
The next problem is that when interpreted as regular expression, the backslash has again different meanings, see perlre, here \d is a meaningful sequence. You need quotemeta() or simply the \Q \E escapes inside the RE:
s/\Q$cache\E//
And btw.: The /g does not make sense here.
--
|
|---|