$/="//\n"; while(<>) { if($_=~/^(\d+)\s+(.*)/m) {$seq_length=$1; $ID=$2;} $seq=''; while($_!~/([A_z]+)/mg) { $part1=$1; $seq.=$seq.$part1; } $top=''; while($_=~/([S\.]+)/mg) {$part2=$1; $top.=$top.$part2;} print ">$ID\n$seq\n$top\n"; } $/="\n";