keys(%dict) returns a list (array) of keys in %dict (in arbitrary order). This can be used with foreach construct:
|
foreach (keys(%mime)) { # $_ is default loop variable
-
print "\$mime{$_} = $mime{$_}\n";
|
}
|
values(%dict) is typically less useful. It returns an unordered list of values (with repetition) in hash %dict
|
each(%dict) returns a single, two-element list containing the "next" key-value pair in %dict. For example,
|
while ( ($key,$val) = each(%dict) ) { ... }
|
Every call to each(%dict) returns a new pair until it finally returns null. The next call to each() starts the cycle again...
|