programming-examples/perl/Hash/Obtain the list of hashKeys and display each key-value pair.pl

12 lines
256 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
%hash = ( Karl => 1,
Joe => 3,
Shawn => 0,
Paul => 2,
Bill => undef );
@hashKeys = keys( %hash );
for ( $i = 0; $i < @hashKeys; ++$i ) {
print "$hashKeys[ $i ] => $hash{ $hashKeys[ $i ] }\n";
}