#! /usr/bin/perl use strict; use warnings; sub display { my $ref = shift; foreach my $key (sort keys %{$ref}) { print "$key = ["; foreach my $key1 (@{$ref->{$key}}) { print "$key1,"; } print "]\n"; } } my %hash1; $hash1{'frog'} = ['jumps','swims','slimy']; $hash1{'dog'} = ['barks','swims','hairy']; display(\%hash1);