#!/usr/bin/perl # indexhash.pl use warnings; use strict; #create a hash with integrated index my %hash = { Mouse => {Index => 0, Value => 'Jerry'}, Cat => {Index => 1, Value => 'Tom'}, Dog => {Index => 2, Value => 'Spike'} }; # sort a hash by integrated index foreach (sort {$hash{$a} {'Index'} cmp $hash{$b} {'Index'}} keys %hash) { print "$hash{$_} {'Value'} <= $_ \n"; } #### Reference found where even-sized list expected at indexhash.pl line 7. Use of uninitialized value in concatenatization (.) or string at indexhash.pl line 16.