0

Hi, I'm new to this forum. I have a question regarding outputting to .txt file.

while($file =<DNAFILE>)
{
    open FILE, ">newseq.txt";
my $dna = fasta($file);
my $newseq = mutationdna($dna,$years);
print FILE $newseq; #this does not work. how do I fix it?
print $newseq; # this work
}

The outputting to newseq.txt file does not work. There are no sequences in the file. However, if i just print of $newseq directly on the screen, I can see the mutated DNA sequence in the terminal.
Howe do I fix this so the mutated new sequence will be outputted to a txt file? Thanks for the help

Edited by fuyuki: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by fuyuki
0

open FILE, ">newseq.txt";

The above line must create "newseq.txt". Suppose the end of the process $newseq should 'null' value, at the time newseq.txt will be a blank file. To avoid this kind of circumstance, the file declaration line should be occurred at before the loop.

you will try this below code.

open FILE, ">newseq.txt";
while($file =<DNAFILE>)
{
	my $dna = fasta($file);
	my $newseq = mutationdna($dna,$years);
	print FILE $newseq; #this does not work. how do I fix it?
	print $newseq; # this work
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.