or even betteruse strict; use warnings; sub main { my $path = "\\\\127.0.0.1\\c\$\\bak\\"; $path =~ s/\\$//; print __FILE__.__LINE__." path $path\n"; return; } main();
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.
In reply to Re: Why I can't remove trailing slash
by kennethk
in thread Why I can't remove trailing slash
by anaconda_wly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |