#!/usr/bin/perl -w use strict; use warnings; my $infile = '/path/to/infile.fa'; my $outfile = '/out/outfile.txt'; my %single_hash; open(INFILE,"<$infile") or die $!; while(my $line = ){ chomp $line; $single_hash{$line} = 1; } close INFILE; open(OUTFILE,">$outfile") or die $!; for my $key(keys(%single_hash)){ print OUTFILE $key,"\n"; } close OUTFILE;