Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: -E behavior with stdin script

by salva (Canon)
on Sep 05, 2021 at 11:51 UTC ( #11136460=note: print w/replies, xml ) Need Help??


in reply to -E behavior with stdin script

AFAIK, there is no way to pick the features enabled by -E automatically other than by using it.

But you can require just what you need inside the code chunk:

perl -wn -- - /etc/passwd <<'EOF' use feature 'say'; next unless / ([^:]*) : [^:]* : ([0-9]+) /x; my ($w, $n) = (uc $1, 5000 + $2); say qq{log=$w id=$n} EOF
That's the most future-proof solution.

Replies are listed 'Best First'.
Re^2: -E behavior with stdin script (updated)
by haukex (Bishop) on Sep 05, 2021 at 13:50 UTC
    AFAIK, there is no way to pick the features enabled by -E automatically other than by using it.

    Well, -E is equivalent to a use feature ':5.XX';, so one slightly hackish way to get the same effect is use feature ":5.".(0+substr($],2,3));.

    Update: Crossposting the following better solution from my other node for completeness:

    use Config; use feature ":$Config{PERL_REVISION}.$Config{PERL_VERSION}";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2022-01-21 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (59 votes). Check out past polls.

    Notices?