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

Re^2: u+ fails to force scalar context to empty list assignment: +( () = ... )

by ikegami (Patriarch)
on Mar 12, 2019 at 00:19 UTC ( [id://1231140]=note: print w/replies, xml ) Need Help??


in reply to Re: u+ fails to force scalar context to empty list assignment: +( () = ... )
in thread u+ fails to force scalar context to empty list assignment: +( () = ... )

Shorter alternative:

>perl -MO=Concise,-exec -e"$a = +f()" 2>&1 | find "entersub" 5 <1> entersub[t3] sKS/TARG >perl -MO=Concise,-exec -e"@a = +f()" 2>&1 | find "entersub" 6 <1> entersub[t4] lKS/TARG >perl -MO=Concise,-exec -e"+f()" 2>&1 | find "entersub" 5 <1> entersub[t2] vKS/TARG

The first letter of the "word" after the op name (entersub) is the context in which it's evaluated.

Replies are listed 'Best First'.
Re^3: u+ fails to force scalar context to empty list assignment: +( () = ... )
by LanX (Saint) on Mar 12, 2019 at 02:32 UTC
    Interesting!

    > Shorter alternative:

    Well ...

    the sub ctxt() is just using the well documented wantarray the rest is only cosmetics to provide readable output.

    If I wanted to golf, I could also do:

    >perl -E"sub f{say qw/s l v/[wantarray//'2']};+f;$a=+f;@a=+f" v s l

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      So your alternatives to $a = +f() are magical code and incomprehensible code?

        No....

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-23 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found