954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

outputing to .txt file

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

fuyuki
Newbie Poster
2 posts since Mar 2010
Reputation Points: 10
Solved Threads: 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
}
k_manimuthu
Junior Poster in Training
93 posts since Jun 2009
Reputation Points: 55
Solved Threads: 24
 

thank you, this solve the problem

fuyuki
Newbie Poster
2 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You