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:
A structure like that doesn't invite to get things out of sync.my @fields = qw/ ... /; for (0 .. $#fields) { get_updates($objects[$_], $fields[$_], $result_ref->{$fields[$_]} if defined $result_ref->{$fields[$_]}; }
ihb
See perltoc if you don't know which perldoc to read!
In reply to Re^2: How would you rewrite this?
by ihb
in thread How would you rewrite this?
by jacques
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |