use List::MoreUtils qw(distinct); my @new = (1..4); my @old = (4..8); @new = distinct(@new, @old); print join(", ", @new);