use strict; use warnings; local $/ = '>'; while (<>) { chomp; my ( $id, $seq ) = /(.+?\n)(.+)/s or next; $seq =~ s/\s+//g; print ">$id$seq\n"; }