#$elements{$id} = \@words; push @{ $elements{$id}->[$_] }, $words[$_] for 0 .. $#words; #... #print "key: $k, value: ".join(', ',@$v).".\n"; print "key: $k\n"; for my $i ( 0 .. $#{$v} ) { print " col $i: ". join( ', ', @{ $v->[$i] } ) ."\n"; }