Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2018-05-24 04:53 GMT
Find Nodes?
    Voting Booth?