in reply to Combining arrays with grep/unless?
One would hope you didn't get that code here since it's doing a linear scan of @group1 for every element of @group2. The way that's in the FAQ is in the FAQ for a reason.
Update: Aaah, you want the union to have only distinct copies of the elements.
my @distinct_union, %seen; for my $e ( @group1, @group2 ) { push @distinct_union, $e unless $seen{ $e }++; }
|
|---|