|Don't ask to ask, just ask|
OS agnostic C&P CLI snippets with -Eby LanX (Sage)
|on Oct 17, 2021 at 18:25 UTC ( #11137651=perlquestion: print w/replies, xml )||Need Help??|
LanX has asked for the wisdom of the Perl Monks concerning the following question:
we often exchange one-liners here or short snippets like the following.
That's very handy for quick demos without the need of a temp file. ( like from kcott here)
unfortunately this sucks on Win/CMD because it doesn't like simple quotes°
The best OS agnostic approach - well the only I'm aware of - is typing to STDIN with a final __END__
So far so good ... (well it's not so good for in-place editing but then a temp file might be better anyway)
But did you notice the -M5.012 I had to add? It means use 5.012 and it's there to compensate the -E which activated all current features. But simply using -E will deactivate reading from STDIN and say was added with 5.12 ... (details perlrun )
Question: Is there a shorter way to do this?
°) the truth is even far worse. One needs to replace the surrounding ' with " and all internal "..." with qq(...) and worry about the right delimiter.
Back to Seekers of Perl Wisdom