Help for this page
my $array = [[apple, a1], [apple, a2], [apple, a3]]; my %hash = (); ... $hash{$_->[0]} = [] unless defined($hash{$_->[0]}); push (@{$hash{$_->[0]}}, $_->[1]); }
use List::Util qw(reduce); ... push(@$a, $b->[1]); $a; } @$array;