Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: do $n exist in grep?

by choroba (Cardinal)
on May 12, 2021 at 17:02 UTC ( [id://11132505]=note: print w/replies, xml ) Need Help??


in reply to Re^3: do $n exist in grep?
in thread do $n exist in grep?

It's also possible to shorten the lines with
('--somearg' => $somearg ) x !! $somearg, ('--otherarg' => $otherarg) x !! $otherarg,

but only if the left hand side of x doesn't have any side-effects (because unlike the ternary operator, foo() x 0 still calls foo).

See also PerlX::Maybe.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^5: do $n exist in grep?
by davido (Cardinal) on May 12, 2021 at 17:26 UTC

    That's interesting. I'm not sure it qualifies as coding for clarity, but perhaps neither does my example.


    Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2026-02-14 23:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.