Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Problems with looping through an array

by hv (Prior)
on May 27, 2004 at 11:48 UTC ( #356866=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://356866]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2023-02-07 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?