in reply to What would you do?

doubling a number seems simpler than doing the modulo, thus:

# change even-numberd list entries to 'hi' foreach $i (0..@list/2) { $double = $i * 2; $list[$double] = 'hi'; }

of course you could do away with the extra variable "$double". loose the variable, insert another line of comment to explain what happens. same difference.

--
Brigitte    'I never met a chocolate I didnt like'    Jellinek
http://www.horus.com/~bjelli/         http://perlwelt.horus.at

Replies are listed 'Best First'.
Re: Re: What would you do?
by indigo (Scribe) on Mar 18, 2001 at 00:20 UTC
    Just a little tighter, without getting too obfuscated:

    $list[$_ * 2] = 'hi' for 0 .. @list / 2;