Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: help declaring variables within perl one-liner

by haukex (Archbishop)
on Apr 01, 2021 at 20:08 UTC ( [id://11130691]=note: print w/replies, xml ) Need Help??


in reply to help declaring variables within perl one-liner

perl one-liners called from another perl script

You've already gotten answers to your question, so let me add: Don't do that! It is hardly ever necessary unless you're doing really fancy stuff, and what you showed here does not fall in that category. See my node here for various examples of editing files and overwriting the originals.

  • Comment on Re: help declaring variables within perl one-liner

Replies are listed 'Best First'.
Re^2: help declaring variables within perl one-liner
by perlfan (Vicar) on Apr 02, 2021 at 05:45 UTC
    >perl one-liners scripts called from another perl script

    One liners are bad enough; but I swear, "shelling-out" to actual Perl scripts from a Perl script is one of the most offensive things I can see in Perl code. All the wasted cycles, dead electrons, PIDs, (oh the horror!) and server fan RPMs that are consumed for no reason ... incidentally in most (but not all) a simple conversion of the called script to a modulino would; then using it as a library rather than a system call would fix all of that. The only exception I've run across is if the called Perl script is specifically being used for sandboxing necessary privilege escallation; in that case, I think it's fine to treat the Perl script as an opaque userland program.

      One liners are bad enough; but I swear, "shelling-out" to actual Perl scripts from a Perl script is one of the most offensive things I can see in Perl code.

      My opinion is actually the other way around: system, when used properly, is less bad than using qx//, because the latter almost always involves the shell and introduces quoting problems - though what I said above still stands, calling another perl is almost never necessary (the most common exception I make is during testing). See Calling External Commands More Safely and The problem of "the" default shell.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11130691]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-19 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found