Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: what's this loo code?

by jdporter (Canon)
on Feb 04, 2003 at 17:44 UTC ( #232603=note: print w/ replies, xml ) Need Help??


in reply to what's this loo code?

just printing the value of the assignment is normally no different from just printing the rhs, so what's the point?
It's all about context. Just printing the RHS evaluates it in list context. The assignment to $= (an unused global variable) forces the assignment to occur in scalar context.
And there's the trick: evaluating a list assignment in scalar context returns the number of items that are (or would be) assigned.
That is why this snippet works to print the number of lines of input.

jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.


Comment on Re: what's this loo code?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://232603]
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 2015-07-06 10:01 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 (71 votes), past polls