use strict; use warnings; use Data::Dumper; local $/=">"; while(my $fasta_record=){ chomp $fasta_record; $fasta_record =~ s/(^>*.+\n)/$1: /; #add a space after the fasta header $fasta_record =~ s/\n//g; # remove endlines print $fasta_record,"\n"; } __DATA__ >protein1 WWWWTCTG TTWTTTCT TTWWWC >protein2 WWWWTCTG TTWWWC TTWTTTCT >protein3 TTWWWC WWWWTCTG TTWTTTCT