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:
and here are the results:#!/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();
What I think you really wanted was to add a backslash before the $ since normally that would have been interpoloated resulting in :$ ./hackslash.pl Use of uninitialized value $\ in concatenation (.) or string at ./hack +slash.pl line 6. ./hackslash.pl8 path \\127.0.0.1\ak
giving you:# note the backslash in front of the dollar sign my $path = "\\\\127.0.0.1\\c\$\\bak\\";
$ ./hackslash.pl ./hackslash.pl8 path \\127.0.0.1\c$\bak
Creating a sub without calling it will act as a NOOP.
|
|---|
| 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 |