in reply to Union of arrays

You probably want to use a hash to keep track of previously seen elements, instead of using nested for loops. Also there are a few other simplifications you could make, such as
# replacing my @union_arr; foreach my $arr_1(@arr_in_1) {push(@union_arr,$arr_1);} # with this: my @union_arr = @arr_in_1;
I would also imagine that taking a look at the internals of a module like Set::Array, or one of the other many Set:: modules that include a union function, might prove insightful. You also may want to check out this recent node, which is a discussion on set membership, but there are some other general-purpose set-related CPAN modules mentioned.

blokhead