in reply to Failed array attemp
You mean like this?
push @z, (grep { $_ ~~ \@y } @x) ? 'y' : 'n';
Shifting some of that into a sub might make it a little more readable...
sub arrays_intersect { grep { $_ ~~ $_[1] } @{$_[0]} } push @z, arrays_intersect(\@x, \@y) ? 'y' : 'n';
Or you could use Set::Scalar...
my $x_set = Set::Scalar->new(@x); my $y_set = Set::Scalar->new(@y); push @z, $x_set->intersection($y_set)->empty ? 'n' : 'y';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Failed array attemp
by Anonymous Monk on May 13, 2012 at 21:46 UTC | |
by tobyink (Canon) on May 13, 2012 at 21:54 UTC | |
by Anonymous Monk on May 13, 2012 at 21:56 UTC | |
by tobyink (Canon) on May 13, 2012 at 22:09 UTC | |
by stevieb (Canon) on May 13, 2012 at 21:57 UTC | |
by Anonymous Monk on May 13, 2012 at 22:01 UTC | |
by stevieb (Canon) on May 13, 2012 at 22:16 UTC | |
by Anonymous Monk on May 13, 2012 at 22:27 UTC |