Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Why I can't remove trailing slash

by blue_cowdawg (Monsignor)
on Apr 19, 2013 at 15:47 UTC ( #1029543=note: print w/ replies, xml ) Need Help??


in reply to Why I can't remove trailing slash

      I want to remove the trailing slash in the path but the code print nothing. Why?

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


Comment on Re: Why I can't remove trailing slash
Select or Download Code
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029543]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
As of 2015-07-28 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls