Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Keeping a Count in foreach

by I0 (Priest)
on Jun 17, 2002 at 18:27 UTC ( #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"); }


Comment on Re: Keeping a Count in foreach
Download Code
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*

      10pts for using map in a void context!


      (loses 2000 xp)
        yeah, nasty code. i should probably give an englishEnglish version as contrast.

        use English; sub ONE() {1} sub ZERO() {0} for my $each (@strings) { print( ( ( $INPUT_LINE_NUMBER or ONE ) .. ( $INPUT_LINE_NUMBER and ZERO ) ) - ONE, ' ', $each, $INPUT_RECORD_SEPARATOR, ); }

        ~Particle *accelerates*

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
Node Status?
node history
Node Type: note [id://175159]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (15)
As of 2014-07-31 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (253 votes), past polls