in reply to Union of arrays

I am going to assume the code was meant to look like so until you fix your code tags.

my @arr_in_1 =("User1","user2","user3"); my @arr_in_2 =("user2","user3","User4"); my @union_arr; foreach my $arr_1(@arr_in_1) { push(@union_arr,$arr_1); } foreach my $arr_1(@arr_in_1) { #print "The value in array 1 is :" .lc $arr_1."\n"; foreach my $arr_2(@arr_in_2) { #print "the value in array 2 is :". lc $arr_2." \n"; if (lc $arr_2 ne lc $arr_1) { push(@union_arr,$arr_2); } } } print "union array @union_arr";
The main problem is the statement lc $arr_2 ne lc $arr_1 which will always result in truth (in this case). For instance think about what is being compared.

first loop(first element in @arr_in_1) vs inner loop(@arr_in_2):
user1 ne user2 (true)
user1 ne user3 (true)
user1 ne user4 (true)
so obviously this is inserted into the union array.

second loop:
user2 ne user2 (false)
user2 ne user3 (true) Again pushed into the union array
...

Well you get my drift. Your on the right track just have to make a couple modifications.

-enlil