Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Keeping a Count in foreach

by I0 (Priest)
on Jun 17, 2002 at 18:27 UTC ( [id://175159]=note: print w/replies, xml ) Need Help??


in reply to Keeping a Count in foreach

foreach $e (@s) { print(($.||1..$.&&0)-1," $e\n"); }

Replies are listed 'Best First'.
Re^2: Keeping a Count in foreach
by particle (Vicar) on Jun 17, 2002 at 19:04 UTC
    if you're going to obfuscate it, why not

    map print(($.||1..$.&&0)-1," $_$/"),@s;
    and be done with it? {shudder}

    ~Particle *accelerates*

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^2: Keeping a Count in foreach
by Anonymous Monk on May 10, 2012 at 03:41 UTC
    Hi can you please explain this syntax ($.||1..$.&&0)-1 , i tried to get it but i am unable to understand it.
Re^2: Keeping a Count in foreach
by Anonymous Monk on May 10, 2012 at 03:41 UTC
    Hi can you please explain this syntax|1..$.&&0)-1 , i tried to get it but i am unable to understand it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-16 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found