in reply to Getting rid of duplicates

You can use a hash to 'remember' which numbers have already been seen:
use 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{$_}++; } }
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::Util