in reply to creating a new file with unique values

Assuming the order of the occurrences doesn't matter, the easiest way would be to store the digits as keys in a hash. Keys are always unique. You could use any value as your hash-value;

$file = "project.txt"; open(FILE,"$file"); my %hash = (); while(my $a=<FILE>) { if($a=~/\tCM+(\d*)/io) { print "$1\n"; $hash{$1}=undef; } } close FILE; open(OUTPUT,">> project.out"); while(my $key = each %hash) { print OUTPUT "$key\n"; } close OUTPUT;
Or how I would probably write it:

my %done=(); open INPUT, "<$inputfile"; open OUTPUT, ">>$outputfile"; while(<INPUT>) { next unless /\tCM+(\d+)/io; next if exists $done{$1}; print OUTPUT, "$1\n"; $done{$1}=undef; ) close INPUT; close OUTPUT;

Haven't tested it, but it should work, and be fast... The <HANDLE> operator and regular expressions have the useful property that they both use the default variable ($_) if you supply none. This way you can bypass the use of $a.