http://qs321.pair.com?node_id=1076057


in reply to Can you make this code shorter and/or quicker as well?

Perhaps the following will be helpful:

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

Command-line usage: perl script.pl fastaIn [>fastaOut]

The last, optional parameter directs output to a file.