Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: How would you rewrite this?

by ihb (Deacon)
on Apr 27, 2005 at 01:37 UTC ( #451821=note: print w/replies, xml ) Need Help??


in reply to Re: How would you rewrite this?
in thread How would you rewrite this?

Note that your code doesn't follow the original with regard to the index. You only increase the index if the if branch is evaluated. You need to increase $i outside the if. I'd probably rewrite it to this though:

my @fields = qw/ ... /; for (0 .. $#fields) { get_updates($objects[$_], $fields[$_], $result_ref->{$fields[$_]} if defined $result_ref->{$fields[$_]}; }
A structure like that doesn't invite to get things out of sync.

ihb

See perltoc if you don't know which perldoc to read!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2020-10-30 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (284 votes). Check out past polls.

    Notices?