#!/usr/bin/env perl -l use strict; use warnings; my %hash = ( numbers => [qw{one two three four five}], fruit => [qw{banana pear apple}], ); { print 'Direct Printing'; print '-' x 40; local $, = ','; print 'All elements combined:'; print map { @{$hash{$_}} } sort keys %hash; print ''; print 'Elements grouped by hash key:'; print @{$hash{$_}} for sort keys %hash; } print ''; { print 'Printing From Variables'; print '-' x 40; local $" = ','; { print 'All elements combined:'; my $statement = "@{[ map { @{$hash{$_}} } sort keys %hash ]}"; print $statement; } print ''; { print 'Elements grouped by hash key:'; for (sort keys %hash) { my $statement = "@{$hash{$_}}"; print $statement; } } }