in reply to slicing array based on values but not index
#!/usr/bin/perl use strict; use Data::Dumper; my %record; my %third_col; my @arr = ( [12, "abc", 30], [24, "abc", 30], [26, "abc", 30], [14, "abc", 40], [46, "abc", 40], [2, "abc", 50] ); $third_col{ $_->[2] }++ for (@arr); for my $i (@arr) { push ( @{ $record{$i->[2]} }, $i ) if ( grep /$i->[2]/, keys %third_col ); } print Dumper \%record;
|
|---|