in reply to Re: using grep with two dimensional arrays
in thread using grep with two dimensional arrays
Note that this can likely be done more efficiently: the inner grep tests all elements, while we only care about whether or not one element matches. But unless the rows are very large, it probably doesn't matter.sub grep2d (&;@) { my $test = shift; grep { grep $test->(), @$_ } @_ } use Data::Dumper; my @array = ( [ 1 .. 3], [ 4 .. 5 ], [ 3 .. 5 ] ); print Dumper grep2d { $_ == 3 } @array;
|
|---|