in reply to Re: Check for next array element.
in thread Check for next array element.

Couldn't that also be written as
$data->{'IS_LAST'} = 0; for ( my $i = 0; $i < @list; $i++ ) { # DO STUFF $data->{'IS_LAST'} = 1 if $i == $#list; }

Don
WHITEPAGES.COM | INC
Everything I've learned in life can be summed up in a small perl script!

Replies are listed 'Best First'.
Re^3: Check for next array element.
by Aristotle (Chancellor) on Nov 18, 2005 at 19:18 UTC

    Too easy to make off-by-one mistakes that way. Use for my $i ( 0 .. $#list ) { ... } instead, unless you have speficic reason to use for(;;). (I have never had such an occasion, but maybe you will.)

    Makeshifts last the longest.

Re^3: Check for next array element.
by friedo (Prior) on Nov 18, 2005 at 18:50 UTC
    Sure, but then in the "DO STUFF" section you have to work with $list[$i] instead of $_. What are we, animals?! :-)