in reply to Re^2: Writing to file...
in thread Writing to file...

Also, if ^^ is not present I need to add it in with a new line character before the sequence.
Something like...
while (<$in>) { if $in =~ /^^/ { s/\^\^/\n^^/g; print $out $_; else { s/[a]|[c]|[t]|[g]{6}/^^\n }

How would I correctly write the else?
I was thinking just find a series of a, c, t, or g's and add the ^^ before it but I don't know how to get the same series of bases in the substitution. Sorry I'm really bad at this lol

Replies are listed 'Best First'.
Re^4: Writing to file...
by Marshall (Canon) on Jul 24, 2009 at 20:59 UTC
    The ^ character has meaning within a regex (anchor the following stuff at the beginning of line). If you want this ^ character be interpreted without the contextual meaning, ie literally, you need to "escape it" with a "\".

    I'm not really sure what you are trying to do here. A simple example with a)I have this "X" and b)I what that "Y" would be helpful. BTW:

    [a]|[c]|[t]|[g]{6} #looks like a char set [actg]{6}