Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Nested Loops vs Good programming

by ikegami (Patriarch)
on Nov 14, 2008 at 20:05 UTC ( [id://723716]=note: print w/replies, xml ) Need Help??


in reply to Re: Nested Loops vs Good programming
in thread Nested Loops vs Good programming

$count is a misnomer in your new code. If you change what a variable contains, you need to change its name too.

Minimal fix (<=<):

my $count = @{ $doc->{$sub1} }; for (my $i=0; $i<$count; $i++)

Easier to read:

my $count = @{ $doc->{$sub1} }; for my $i ( 0 .. $count-1 )

Alternative:

my $last = $#{ $doc->{$sub1} }; for my $i ( 0 .. $last )

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-20 00:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found