note
Kenosis
<p>Here's one option:</p>
<c>
use strict;
use warnings;
for my $fastaRec ( extract_query_data('fastaFile.fa') ) {
print $fastaRec, "\n";
}
sub extract_query_data {
my ($file) = @_;
my @arr;
local $/ = '>';
open my $fh, '<', $file or die $!;
while (<$fh>) {
chomp;
my ( $id, $seq ) = /(.+?\n)(.+)/s or next;
$seq =~ s/\s+//g;
push @arr, ">$id$seq";
}
close $fh;
return @arr;
}
</c>
<p>You'll note that the subroutine returns an array of fasta records.</p>
1076056
1076060