my @a; while (my $val = <>) { chomp $val; push @a, $_ if !grep $_ eq $val, @a; }