|Pathologically Eclectic Rubbish Lister|
Re: OS agnostic C&P CLI snippets with -Eby kcott (Bishop)
|on Oct 18, 2021 at 19:47 UTC||Need Help??|
For the most part, I provide complete scripts. Generally, you can use the [download] link, save the code, and run it as is; sometimes it may be necessary to change a local value, e.g. my $path = '...' (or similar).
For code that is mostly simplistic and provided for demonstration purposes, I will, in the main, use this type of format: $ perl -E '...'
In "Re: POD for use feature 'declared_refs' wrong", you'll see a whole series of these built up using very small changes. There was no way that I was going to create five separate (almost identical) scripts for this.
The demonstration code is really just that; however, it's perfectly acceptable and reasonable to check that the results are the same on your OS, Perl version, or whatever. I'm certainly no MS-DOS expert; but the following seemed like a very easy way to achieve this.
Get the version to which -E would refer; e.g.
Create a Perl script (e.g. pm_11137651_os_agnostic.pl) that starts with use <-E version>; (that's use 5.026; in this instance). Copy the ... part of perl -E '...' exactly and paste it after the first line. Save the file. Using the first piece of code from the OP, that should look like this:
Then run it:
A verbatim copy of pm_11137651_os_agnostic.pl, on a Unix-style OS (Cygwin), acted in exactly the same way (except I needed cat instead of more).
As I indicated, I'm no expert on the MS-DOS front. There may be quicker or better ways to do this; although, this method literally only took a few seconds. Perhaps, if this is needed often, some sort of script might be a valid choice.