Logo

Programming-Idioms

History of Idiom 13 > diff from v76 to v77

Edit summary for version 77 by lpi:
New Perl implementation by user [lpi]

Version 76

2019-12-28, 21:05:38

Version 77

2020-02-13, 19:59:59

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
printf "Key=%s, Value=%s\n",$_,$mymap{$_} foreach (sort keys %mymap);

Comments bubble
one-line style with keys sorted