in reply to Why I can't remove trailing slash

Added exactly one line to your code and got results. Here's the new code:

#!/usr/bin/perl -w use strict; use warnings; sub main { my $path = "\\\\127.0.0.1\\c$\\bak\\"; $path =~ s/\\$//; print __FILE__.__LINE__." path $path\n"; return; } main();
and here are the results:
$ ./hackslash.pl Use of uninitialized value $\ in concatenation (.) or string at ./hack +slash.pl line 6. ./hackslash.pl8 path \\127.0.0.1\ak
What I think you really wanted was to add a backslash before the $ since normally that would have been interpoloated resulting in :
# note the backslash in front of the dollar sign my $path = "\\\\127.0.0.1\\c\$\\bak\\";
giving you:
$ ./hackslash.pl ./hackslash.pl8 path \\127.0.0.1\c$\bak

Creating a sub without calling it will act as a NOOP.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^2: Why I can't remove trailing slash
by anaconda_wly (Scribe) on Apr 20, 2013 at 01:32 UTC
    Thank you all.... Funny question. My head freezed. And all replies wonderful.