Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

G'day Rolf,

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.

C:\Users\ken\tmp>perl -v This is perl 5, version 26, subversion 3 (v5.26.3) built for MSWin32-x +64-multi-thread ...

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:

C:\Users\ken\tmp>more pm_11137651_os_agnostic.pl use 5.026; use strict; use warnings; use feature "declared_refs"; no warnings "experimental::declared_refs"; say ref my \$scalar; say ref my \@array;

Then run it:

C:\Users\ken\tmp>perl pm_11137651_os_agnostic.pl SCALAR ARRAY

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).

ken@titan ~/tmp $ cat pm_11137651_os_agnostic.pl use 5.026; use strict; use warnings; use feature "declared_refs"; no warnings "experimental::declared_refs"; say ref my \$scalar; say ref my \@array;
ken@titan ~/tmp $ perl pm_11137651_os_agnostic.pl SCALAR ARRAY

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.

— Ken


In reply to Re: OS agnostic C&P CLI snippets with -E by kcott
in thread OS agnostic C&P CLI snippets with -E by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-26 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found