open(IN, '<', 'myfile') or die "Could not read file\n"; my @array_with_duplicates = ; close IN; @array_with_duplicates = sort @array_with_duplicates; clean_list(@array_with_duplicates); open(OUT, ">", "myfile.NO_DUPLICATES") or die "Could not create file\n"; print OUT @array_no_duplicates; close OUT;