#!/usr/bin/perl -w use strict; sub display { my $ref = shift; for my $k (sort keys %$ref){ print "$k: @{$ref->{$k}}\n"; } } my %hash1; $hash1{fruit} = [ qw/apple orange plum/ ]; $hash1{vegetable} = [ qw/leek carrot peas/ ]; display (\%hash1); for my $k (sort keys %hash1){ print "$k: @{$hash1{$k}}\n"; }