programming-examples/perl/Hash/Reverse a hash- use key as the value, and value as the key.pl
2019-11-15 12:59:38 +01:00

9 lines
188 B
Perl

$hash{fruit} = apple;
$hash{sandwich} = hamburger;
$hash{drink} = bubbly;
%reversed = reverse %hash;
foreach $key (sort keys %reversed) {
print "$key => $reversed{$key}\n";
}