Logo

Programming-Idioms

History of Idiom 13 > diff from v67 to v68

Edit summary for version 68 by daxim:
[Perl] add docs, use var names from problem description

Version 67

2019-09-26, 22:49:01

Version 68

2019-09-29, 17:37:32

Idiom #13 Iterate over map keys and values

Print each key k with its value x from an associative array mymap

Illustration

Idiom #13 Iterate over map keys and values

Print each key k with its value x from an associative array mymap

Illustration
Extra Keywords
table dictionary hash traverse traversal
Extra Keywords
table dictionary hash traverse traversal
Code
while ( ($k,$v) = each %mymap) {
    print "Key=$k, Value=$v\n";
}
Code
while (my ($k, $x) = each %mymap) {
    print "Key=$k, Value=$x\n";
}
Doc URL
http://p3rl.org/each