Use a flag to capture the multiple lines. Remove the spaces with a regex.
pojmy %hash=(); my $seq; my $flag = 0; while (<$ufh>) { chomp; if ( /^(AC|OS|OX|ID|GN|SQ)\s+(.*)/ ){ print "<$1> <$2>\n"; $hash{$1} = $2; $flag = 1 if /SQ/; } elsif (/^K\s+/){ $flag = 0; } elsif ($flag == 1){ s/ +//g; # remove spaces $seq .= $_."\n" } } print Dumper \%hash; print $seq;
In reply to Re^3: Converting Uniprot File to a Fasta File in Perl
by poj
in thread Converting Uniprot File to a Fasta File in Perl
by pearllearner315
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |