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


in reply to add letters to the begin of the sentence

G'day intect,

This technique should do what you want:

$ perl -Mstrict -Mwarnings -e ' my @fasta = (">dddd\n", "abcdef\n", ">eeee\n", "bcdef\n"); for (@fasta) { print "aaaa" unless /^>/; print; } ' >dddd aaaaabcdef >eeee aaaabcdef

Using your filehandles, that would be:

while (<$input_fh>) { print $output_fh 'aaaa' unless /^>/; print $output_fh $_; }

If the ACGAGTGCGT in your code is supposed to be the aaaa in your description, then just make the appropriate substitution. If it isn't, a clarification would be useful.

-- Ken