Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^7: Keeping a Count in foreach

by metadoktor (Hermit)
on Jun 21, 2004 at 21:46 UTC ( #368558=note: print w/replies, xml ) Need Help??


in reply to Re^6: Keeping a Count in foreach
in thread Keeping a Count in foreach

Your use of
($. || 1 .. undef) -1
totally baffles me. This must be an obscure effect. I read this as a scalar use of the range operator with start and stop conditions but you say that it's in list context instead.

I can reduce this to:

((undef or 1) .. undef) - 1
but no more.

Can you shed more light on what anonymous variable is keeping count?

metadoktor

"The doktor is in."

Replies are listed 'Best First'.
Re^8: Keeping a Count in foreach
by runrig (Abbot) on Jun 21, 2004 at 22:22 UTC
    Can you shed more light on what anonymous variable is keeping count?

    The flip-flop range operator remembers its state, so in a way, each flip-flop has it's own anonymous variable. And it is in scalar context.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2019-07-20 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?