(Well I know this question is old, but it's so rare things other than html and js that I can not resist ...)
#!/usr/bin/perl
use strict;
sub ler_fasta { my $file=shift;
local $/="'>'"; # separador de registo= '>'
my %val;
open(FASTA, "fasta.txt") or die "Nao foi possivel abrir o arquivo: $!";
while( <FASTA>) { chomp;
if(/(.+)\n(.+)/){ $val{$1}=$2 }
}
return \%val
}
In this way the values are associated with the identifier (Ex: print $val->{Pvivax_1}
)
use Data::Dumper; print Dumper( ler_fasta("fasta.txt"))
gives
$VAR1 = { 'Pvivax_2' => 'TTGGCCC',
'Pvivax_1' => 'AAGGTTT'
};