#!/usr/bin/perl use strict; use warnings; my %bar = ( # Name => [Age, Pets, Profession] 'Grant'=>[29,4,'Doctor'], 'Roberts'=>[32,1,'Priest'], 'Johnson'=>[29,3,'MD'], 'Harper'=>[23,2,'Student'] ); # sort by age and print foreach my $name ( sort { $bar{$b}[0]<=>$bar{$a}[0] } keys %bar ) { my ($age,$pets,$prof) = @{$bar{$name}}; print "Name: $name\nAge: $age\nPets: $pets\nProf: $prof\n"; } # end-foreach exit;