in reply to Getting rid of duplicates
This method preserves the original order of the numbers. Generally, testing for containment is possible for hashes via the exists function. For arrays you would need to use grep or the first function from List::Utiluse strict; use warnings; my %numbers; open my $in, "infile" or die $!; open my $out, ">outfile" or die $!; while (<$in>) { chomp; if (not exists $numbers{$_}) { print $out "$_\n"; $numbers{$_}++; } }
|
|---|