Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: meaning of =()=

by ikegami (Pope)
on Jan 04, 2010 at 17:39 UTC ( #815613=note: print w/ replies, xml ) Need Help??


in reply to meaning of =()=

=()= is not an operator.

$scalar =()= EXPR
is a funky way of writing
$scalar = ( () = EXPR )

It consists of two operations: a list assignment (() = EXPR) as the RHS of a scalar assignment ($scalar = ...). Both types of assignments are documented in perlop, but the bits that apply are:

  • The RHS of a list assignment is evaluated in list context.
  • The RHS of a scalar assignment is evaluated in scalar context.
  • A list assignment in scalar context returns the number of elements returned by its RHS.

In short, it's a means of evaluating an expression in list context and returning the number of elements returned instead of the elements themselves.

See Mini-Tutorial: Scalar vs List Assignment Operator


Comment on Re: meaning of =()=
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2015-07-01 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (19 votes), past polls