in reply to Bioinformatic task
You don't saywhy it needs to be that way.
If your two arrays are the pre-requisite for other code, then go for it. But I think it would be better to use a hash, with the header as the key and the sequence as the value. If you might have multiple instances of a header, use arrays of sequences as the values:
while ( my $header = <$fh> ) { my $sequence = <$fh>; chomp ( $header, $sequence ); $data{$header} = $sequence; # or push @{ $data{header} }, $sequence; # to read print "$_ -> $data{$_}.\n" for sort keys %data; # or for the hash of arrays for my $key ( sort keys %data ) { print "$key : $_.\n" for @ { $data{$key} }; }
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
|
|---|