my @a; my %seen; while (<>) { chomp; next if $seen{$_}++; push @a, $_; }