Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Newbie question: Where do I place the "print results to file statement" in Perl?

Expand Messages
  • MJ
    Hello all, now my code says: print on closed file handle at line in yourcode.pl any ideas why this is happening? mj4chem wrote: Hello all,
    Message 1 of 2 , Oct 17, 2007
      Hello all, now my code says: print on closed file handle at line in yourcode.pl
      any ideas why this is happening?

      mj4chem <mj4chem@...> wrote:
      Hello all, I am teaching myself some programming.
      I know to get the filename via STDIN. My question: I want the
      contents processed via a small subroutine.

      Where do I place the open file and print staements?

      Here is the code:
      #usr/bin/local;
      use strict;
      use warnings;

      print "PLEASE ENTER THE FILENAME OF THE YOUR SEQUENCE:=";
      chomp($seq_filename=<STDIN>);
      #
      open(PROTFILE,$seq_filename) or die "unable to open the file";
      @seq=<PROTFILE>;
      close PROTFILE;
      #
      #
      foreach $newline (@seq) {
      #
      ## discard blank newline
      if ($newline =~ /^\s*$/) {
      next;

      ## discard comment newline
      } elsif($newline =~ /^\s*/) {
      next;

      # discard fasta header newline
      } elsif($newline =~ /^>/) {
      next;

      ## keep newline, add to sequence string
      } else {
      $sequence1 .= $newline;
      }

      }

      # remove non-sequence data (in this case, whitespace) from $sequence
      string
      #Remove whitespace
      $newline =~ s/\s//g;
      @seq=split("",$newline); #splits string into an array

      print " \nThe original file is:\n$sequence1 \n";

      exit;





      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.