Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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 = "\\\\\\c$\\bak\\"; $path =~ s/\\$//; print __FILE__.__LINE__." path $path\n"; return; } main();
and here are the results:
$ ./ Use of uninitialized value $\ in concatenation (.) or string at ./hack line 6. ./hackslash.pl8 path \\\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 = "\\\\\\c\$\\bak\\";
giving you:
$ ./ ./hackslash.pl8 path \\\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?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2015-10-04 11:29 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (102 votes), past polls