programming-examples/perl/Hash/each function returns both key and value in a hash.pl

7 lines
147 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
$hash{fruit} = orange;
$hash{sandwich} = club;
$hash{drink} = lemonade;
while (($key, $value) = each %hash ) {
print "$key: $value\n";
}