in reply to Joining elements of an array in a hash

You don't need the intermediary @group there, you can do the whole shebang in one go:

use warnings; use strict; my @array1 = ("one", "two", "three", "four", "five"); my @array2 = ("banana", "pear", "apple"); my %hash = ( numbers => \@array1, fruit => \@array2 ); for my $group (keys %hash){ my $statement = join ', ', @{ $hash{$group} }; print "$statement\n"; }

Output:

one, two, three, four, five banana, pear, apple

Replies are listed 'Best First'.
Re^2: Joining elements of an array in a hash
by orangepeel1 (Novice) on Mar 26, 2017 at 18:22 UTC
    great, thank you!