942,792 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Marked Solved
  • Views: 456
  • Perl RSS
Mar 8th, 2010
0

outputing to .txt file

Expand Post »
Hi, I'm new to this forum. I have a question regarding outputting to .txt file.
Perl Syntax (Toggle Plain Text)
  1. while($file =<DNAFILE>)
  2. {
  3. open FILE, ">newseq.txt";
  4. my $dna = fasta($file);
  5. my $newseq = mutationdna($dna,$years);
  6. print FILE $newseq; #this does not work. how do I fix it?
  7. print $newseq; # this work
  8. }

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
Last edited by fuyuki; Mar 8th, 2010 at 5:04 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fuyuki is offline Offline
2 posts
since Mar 2010
Mar 8th, 2010
0
Re: outputing to .txt file
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.

Perl Syntax (Toggle Plain Text)
  1. open FILE, ">newseq.txt";
  2. while($file =<DNAFILE>)
  3. {
  4. my $dna = fasta($file);
  5. my $newseq = mutationdna($dna,$years);
  6. print FILE $newseq; #this does not work. how do I fix it?
  7. print $newseq; # this work
  8. }
Reputation Points: 55
Solved Threads: 24
Junior Poster in Training
k_manimuthu is offline Offline
93 posts
since Jun 2009
Mar 8th, 2010
0
Re: outputing to .txt file
thank you, this solve the problem
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fuyuki is offline Offline
2 posts
since Mar 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: read data file then calculate parameter
Next Thread in Perl Forum Timeline: matching array index





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC