P is for Practical | |
PerlMonks |
Re^2: What is the meaning of this line in Perl on linux?by Marshall (Canon) |
on Mar 29, 2022 at 02:22 UTC ( [id://11142474]=note: print w/replies, xml ) | Need Help?? |
Wow! lots of LTS discussion! I would prefer: s|/|\\|g; to s{/}{\\}g; but they are equivalent. I also like your idea of using a module for the translation. However, I am perplexed as to why the OP wants to do that in the first place? I write a lot of Perl on Windows and Windows just isn't DOS anymore. Modern Windows is fine with forward slashes. Better than good code is: "no code". I don't see the need to convert forward slashes to back slashes. Having said that, I do have a vague recollection of some command from the Windows command line where I had to use backslash as part of the path to get the command to work. This may have been a legacy issue with ancient MS code. I have never seen such a requirement when using Perl. It could exist, but I haven't come across it yet. Anyway, my advice is "don't run a format conversion where it is not necessary". Update: Clarification: On the command line, Windows will display back slash, but that does not mean that you have to use them: A Perl program is not getting what Windows displays for its command line.
In Section
Seekers of Perl Wisdom
|
|