[Solved] How do I read strings into a hash in Perl [closed]


Not completely clear on what you want; maybe this:

my $seq;
my %idSeq;
while ( my $line = <$INPUT> ) {
    if ( my ($name) = $line =~ /^>(.*)/ ) {
        $idSeq{$name} = length $seq || 0;
    }
    else {
        chomp $line;
        $seq .= $line;
    }
}

which produces:

$seq = 'ACGTACGTACGTACCCCGGCCCCTAAAAAAAAAAAT';
%idSeq = (
      'Mary' => 0,
      'Jane' => 14,
      'Arthur' => 25,
);

solved How do I read strings into a hash in Perl [closed]