my %hash; @hash{@monthly_temp} = 1; for(@temp){ push(@monthly_temp,$_) unless(exists $hash{$_}); }