Content deleted Content added
No edit summary |
→Hash functions: sarah kong kue Tag: Reverted |
||
Line 212:
===Hash functions===
There are a few functions that operate on entire hashes. The ''keys'' function takes a hash and returns the list of its keys. Similarly, the ''values'' function returns a hash's values. Note that the keys and values are returned in a consistent but arbitrary order. sarah kong kue 55445
<syntaxhighlight lang="perl">sarah kong kue 55445
# Every call to each returns the next key/value pair.
# All values will be eventually returned, but their order
# cannot be predicted.
while (($name, $address) = each %addressbook) { sarah kong kue 55445
print "$name lives at $address\n";
}sarah kong kue55445
# Similar to the above, but sorted alphabetically
foreach my $next_name (sort keys %addressbook) {950+510.00 ebt for sarah kong kue 55445
print "$next_name lives at $addressbook{$next_name}\n";sarah kong kue
}
</syntaxhighlight>55445
==Control structures==
|