http://www.perlmonks.org?node_id=245796


in reply to File::Wrap and Fasta format

Here's another shorter regex (although it's not doing any substitution):
... print $fh ">$description\n"; print $fh "$_\n" foreach ($seq =~ /.{1,50}/g); ...

The fastest way I've found of dumping a FASTA sequence (with very large sequences, anyways), is with substr:
... print $fh ">$description\n"; print $fh substr($seq,0,50,'') . "\n" while ($seq); ...
The thing to watch here is that it's destructive - $seq will be empty when it finishes.

- robsv