Ok. Excellent point!
You point out what was probably the cause of my vaguely remembered problem: "However, Windows commands typically use forward slash for command line argument options". If forward slash means "option" then the command will "barf" with a forward slashed file path because it thinks that part of the file path is an option! That explains my error case!
I think we are in 100% agreement about file paths within Perl. Perl itself will always get forward slashed file names. Always use forward slash for file paths within Perl programs.
There is an exception if you want to launch a Windows system command. That may barf due to conflicts between an option switch vs a file path.
If you need to do a translation for that reason, I would put a comment in the code as to why the "/" is being translated to "\".
I stand by my recommendation not to translate formats unless you need to.
Your suggestion about tr is also to be commended. For a one 2 one translation, nothing beats tr for performance. |