in reply to Split according to \
Use the regex syntax, /\\/, not the string syntax. You see, Perl needs to see two backslashes in the regex, but if you use the string syntax, you already lose one before the regex engines gets to see it. If you use a regex, it's passed like you see it in the source code.
This prints a single backslash. So that's what the regex engine see, too. If you had used 4 backslashes, then it would have worked.print "\\"; # a backslash
print "\\\\"; # two backslashes
@file = split ("\\\\",$file); # split on a single backslash
It's the same situation in PHP, BTW, where there is no native built-in syntax for regexes, but only strings. In Perl, it's easier to use a regex, and no reason not to. And you don't need to use that many parens.
@file = split /\\/,$file; # split on a single backslash
|
|---|