my ($k,$v, %seq); for my $line (<DATA>) { chomp ($line); if ( $line=~/^>(\S+)\s*(.*)/){ $k=$1; $v=$2; }else{ $v=$line; } $seq{$k} .= $v; } #---- Print it ---- for my $k(sort keys %seq){ print "$k \t=> $seq{$k}\n"; } # --- Output ---(Using the __DATA__ block above) ..- # 123 => blahabcdefghijkl # 456 => de dahmnopqr # 789 => nothing wanted herestuvwxyz
All great truths begin as blasphemies.
― George Bernard Shaw, writer, Nobel laureate (1856-1950)
In reply to Re^5: Creating 2 arrays from a larger array
by NetWallah
in thread Creating 2 arrays from a larger array
by imtakinbioinformatic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |