Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Why I can't remove trailing slash

by kennethk (Monsignor)
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 = "\\\\127.0.0.1\\c\$\\bak\\"; $path =~ s/\\$//; print __FILE__.__LINE__." path $path\n"; return; } main();
or even better
use strict; use warnings; my $path = <<'EOT'; \\127.0.0.1\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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-08-23 21:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls