Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Why I can't remove trailing slash

by kennethk (Abbot)
on Apr 19, 2013 at 15:44 UTC ( #1029541=note: print w/replies, xml ) Need Help??

in reply to Why I can't remove trailing slash

Because you never call the main subroutine.
use strict; use warnings; sub main { my $path = "\\\\\\c\$\\bak\\"; $path =~ s/\\$//; print __FILE__.__LINE__." path $path\n"; return; } main();
or even better
use strict; use warnings; my $path = <<'EOT'; \\\c$\bak\ EOT $path =~ s/\\$//; printf "%s %s path %s\n", __FILE__, __LINE__, $path;

Unlike C or Java, you don't need a main subroutine; the script just runs in the order it's written, like a shell script. Note as well that I had to escape your $ since " interpolates - you were inserting $\ into your $path assignment. If you'd actually run your subroutine, you would have gotten a warning.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029541]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-02-17 20:04 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (249 votes). Check out past polls.