in reply to Check for next array element.
If that's what you need you need to either use a C style for or iterate over the array indices instead of the array itself.
for my $i ( 0 .. $#list ) { $data->{"IS_LAST"} = $i < $#list ? 0 : 1; ## ... }
Another alternative would be to iterate over all items save the last and then process the last item seperately.
for my $item ( @list[ 0 .. $#list - 1 ] ) { process_item( $item, 0 ); } process_item( $list[ $#list ], 1 );
|
|---|