Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

clairudjinn

by clairudjinn (Beadle)
on Jul 25, 2002 at 16:18 UTC ( #185239=user: print w/replies, xml ) Need Help??

He just made it so simple...

Here follows the account of clairudjinn, and the finding of the Ring of List Assignment in Scalar Context:

On Wed, 9 Oct 2002, clairudjinn wrote:
"...except maybe Schwartz or folks like that? I'll go there if you won't answer. I'll go insane if you can't. Either way, I can say I emailed the creator of Perl. Weeeeee. About my query... The following is from page 75 in the Camel:

List assignment in scalar context returns the number of elements produced by the expression on the right side of the assignment:

$x = ( ($a, $b) = (7,7,7) ); #set $x to 3, not 2

...why?"

>>>Because then you can use it for a boolean value:

while (($a,$b) = somefunc()) { ... }

If it used the number of elements on the left, it would always be true.

"...how.?"

>>>It counts them. :-)

Larry

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
erix denies everything
[shmem]: erix: bad idea. PerlMonks is based on everything
[robby_dobby]: shmem:everything2
robby_dobby says Sorry and points to his boredom
[shmem]: robby_dobby: since everything is everything, it is thus also everything2. And everything2 is based on... you name it.
[Corion]: Mhhmmm. I just had to remind two contractos of their priorities from my point of view. This felt somewhat like getting my godson+siblings to clean their room, including the evil eye I threw them ;)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2017-04-25 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (454 votes). Check out past polls.