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

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.

Comment on Re: Why I can't remove trailing slash
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2015-10-10 15:25 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (257 votes), past polls