Try $var =~ tr!\\!/!;
But if you're using ActiveState Perl then be aware that the built-in operators and functions understand slashes in all directions anyway. | [reply] [d/l] |
$var =~ tr!\\!/! didn't work - this just split out the \ slashes.
the problem seems to be that the forward slashes in the variable are not interpreted as such so c:\dir would not work whereas we know c:\\dir would be interpreted as c:\dir and would work.
i think i need to find a way of returning the path from my html form with \\ instead of \ each time. i wonder if cgi.pm has an ability to convert paths?
| [reply] |
If I'm right in my guess about what you're trying to do, then the answer is "yes, CGI.pm does do it all for you". That's to say, if you're dealing with form input from a form that has a tag like <INPUT TYPE="FILE" NAME="FILENAME"> then if you do
my $fh = param('FILENAME');
while (<$fh>) {
do_stuff_with($_); # manipulate the file line by line
}
CGI.pm will deal with the path in the appropriate way - at least, that's been my experience when receiving input from browsers on Windows systems and processing it on a Linux system.
(BTW you might want to use the upload() method, but as this comes only with later versions of CGI.pm I mention the old-fashioned way, in case you are stuck with an annoying ISP.)
CGI.pm does the thinking so you can spend more time drinking beer :)
§ George Sherston | [reply] [d/l] [select] |
| [reply] [d/l] [select] |
| [reply] [d/l] |
| [reply] [d/l] [select] |