http://www.perlmonks.org?node_id=175159


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.