in reply to Get even postion elements in an array

TIMTOWTDI: Here is a way using a c-like loop:
for (my$i=1; $i <= $#input; $i++) { push (@output, $input[$i++]) };
You teacher will be fascinated by your double-usage of $i++ ;-)    ......don't do this in production-code!

Replies are listed 'Best First'.
Re^2: Get even postion elements in an array
by roboticus (Chancellor) on Nov 16, 2010 at 13:18 UTC

    Ratazong:

    If you're going to use a C-style loop, why use the extra $i++?

    for (my $i=1; $i<=$#input; $i+=2) { push @output, $input[$i] }

    ...roboticus