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


in reply to Problems with looping through an array

When you encounter a new value:

elsif($evr_id != $a) { print "$processed) $evr_id-$count\n\n"; $count = 1; ...
it s correct to initialise the count to 1, because you've just seen the first example of the new value.

When you first enter the loop, though, you haven't yet seen the first example of the initial number. So you should be initialising $count to 0 before the loop, not 1.

Hugo