On 04/17/2013 02:45 PM, Andy Bach wrote:
while ( ($key2, $value2) = each %names ) {and the better idiom is; foreach my $key ( keys %names ) { print "got: $key => $names{$key}\n" }
actually IMO the while/each loop is the better (and lesser known) idiom. it is more efficient as you don't need to do any hashing on the key and it doesn't generate a list of keys as it just iterates over the key/value pairs. each is not taught nearly enough.
uri -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
