in reply to Converting all occurrences of \ to \\ oddity
I was doing something like this on win32 (win2k), and I found that if you simply use forward slashes in single quotes, the code becomes easier to read, and DOS still understands it.Such as:
$dirname='c:/dir/textfile.txt'I eventually wanted to convert the slashes to backslashes for logging (so that I could copy log output directly to a command prompt). I inserted this little bit into the end:
('/' to '\')
conversely '\' to '/':foreach (@files){ s/\//\\/g; }
and your answer('\' to '\\'):foreach (@files){ s/\\/\//g; }
foreach (@files){ s/\\/\\\\/g; }
I would still simply avoid this and use the forward slash if you can...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Converting all occurrences of \ to \\ oddity
by Adam (Vicar) on Sep 12, 2000 at 20:50 UTC | |
by tye (Sage) on Sep 12, 2000 at 21:08 UTC |