in reply to a hash with priority

You can check if a priority already exists with if (exists $hash{20}){...}

further

foreach my $priority (sort keys %hash) { print "Priority: $priority\n"; foreach (keys %{$hash{$priority}}) { print "\t $_ => $hash{$priority}{$_}\n"; } }