#!/usr/bin/env perl use 5.014; use strict; use warnings; { local $/ = "\n>"; while () { chomp; substr $_, 0, 1, '' if $. == 1; my ($head, $seq) = split /\n/, $_, 2; printf "%-15s %s\n", $head, $seq =~ y/\n//dr; } } __DATA__ >SEQ1 AAA >SEQ2 AAA CCC >SEQ3 AAA CCC GGG >SEQ4 plus ... AAA CCC GGG TTT #### SEQ1 AAA SEQ2 AAACCC SEQ3 AAACCCGGG SEQ4 plus ... AAACCCGGGTTT