my @union = array_union_sort(\@first, \@second); sub array_union_sort { my $aa = shift; my $bb = shift; my %union; my $e; foreach $e (@$aa) { $union{$e} = 1; } foreach $e (@$bb) { $union{$e} = 1; } my @union = keys %union; @union = sort { $a <=> $b } @union; return @union; }
You need to create an account or log in to post comments to this site.
sub array_union_sort {
my ($aa, $bb) = @_;
my %union;
foreach my $e (@$aa, @$bb) { $union{$e} = 1; }
my @union = sort keys %union;
return @union;
}
That's without really thinking about whether this is even a good way to do it. Its worth taking half the lines out anyway, right?