Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Write to multiple files

by julio_514 (Acolyte)
on Feb 07, 2012 at 02:36 UTC ( [id://952201]=note: print w/replies, xml ) Need Help??


in reply to Re: Write to multiple files
in thread Write to multiple files

Many thanks!:D It works fine now. I realized I could speed up thing modifying some code and using a hash. Here's what I came up with.
my %handle = (); my $ref_db = FastaDb->new($fasta) or die("Unable to open Fasta file, $ +fasta\n"); while( my $seq = $ref_db->next_seq() ) { if($seq->header() =~ m/(K[0-9]{5})/){ my $ko = $1; if(!exists $handle{$ko}){ open my $fh, ">>".$outdir.$ko.".fasta"; $handle{$ko} = $fh; } print {$handle{$ko}} $seq->header()."\n".$seq->seq()."\n"; } } map { close $handle{$_} } keys %handle;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://952201]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-03-29 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found