Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Problems with looping through an array

by hv (Prior)
on May 27, 2004 at 11:48 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-06-20 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.