in reply to Re^2: How to avoid using array in concatenating string of multiple lines
in thread How to avoid using array in concatenating string of multiple lines OR How To Read FASTA

Then open the file within the for-loop:

#!/usr/bin/perl -w use strict; use Bio::SeqIO; my $file = $ARGV[0]; for (my $trial = 1; $trial <=2; $trial++) { open INFILE, "<$file" or die "$0: Can't open file $file: $!"; seek(INFILE,0,0); #This is line 10 print "Trial $trial\n"; my $i =1; my $in = Bio::SeqIO->new(-format => 'fasta', -fh => \*INFILE); while( my $seq = $in->next_seq ) { print $i++, " : ", $seq->seq(), "\n"; } }
  • Comment on Re^3: How to avoid using array in concatenating string of multiple lines
  • Download Code

Replies are listed 'Best First'.
Re^4: How to avoid using array in concatenating string of multiple lines
by monkfan (Curate) on Dec 10, 2004 at 08:57 UTC
    Thanks so much for the answer reneeb.

    But as I stated in my 2nd posting of this thread. We don't need both. Namely, we don't even need "seek" function at all,
    if we put "open INFILE.." within for-loop. It will work, that I know.

    Forgive me if I sound nitpicking. But I just wonder if we can do
    something by keeping "open" function outside for-loop,
    while maintaining "seek" within? Would it be more efficient?

    Regards,
    Edward