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

12 lines
251 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
%presidents = ( George => "A",
Abe => "B",
Thomas => "C",
Harry => "D" );
@keys = keys( %presidents );
while ( $key = pop( @keys ) ) {
print "$key => $presidents{ $key }\n";
}