julio_514 has asked for the wisdom of the Perl Monks concerning the following question:
What I'd like to do is to avoid opening fh each time I have a hit, but rather open them all before the while loop.my $ref_db = FastaDb->new($fasta); while( my $seq = $ref_db->next_seq() ) { foreach(@ko_array){ if($seq->header() =~ m/($_)/){ open(OUT, ">>".$outdir.$_.".fasta"); print OUT $seq->header()."\n".$seq->seq()."\n"; close(OUT); } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Write to multiple files
by kcott (Archbishop) on Feb 06, 2012 at 21:17 UTC | |
by BrowserUk (Patriarch) on Feb 06, 2012 at 22:17 UTC | |
by jwkrahn (Abbot) on Feb 07, 2012 at 02:30 UTC | |
by julio_514 (Acolyte) on Feb 07, 2012 at 02:36 UTC | |
|
Re: Write to multiple files
by kielstirling (Scribe) on Feb 06, 2012 at 21:14 UTC | |
|
Re: Write to multiple files
by MidLifeXis (Monsignor) on Feb 07, 2012 at 13:50 UTC |