my @array_q3=(); #create the array to store all words in the file open INFILE3, ") { chomp $line3; push @array_q3, $line3; } close INFILE3; #sort the array so we can identify the duplicates my @sorted_array_q3 = sort(@array_q3); my @unique_array; #iterate through the sorted array and check for unique elements foreach my $element ( @sorted_array_q3 ) { if ( ! grep( /$element/, @unique_array ) ) { push( @unique_array, $element ); } } #print the unique elements in the file clean.acc\n"; open OUTFILE3, ">unique_codes"; for (my $m=0; $m<=$#unique_array; $m++) { print OUTFILE3 $unique_array[$m]."\n"; } close OUTFILE3;