Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Can't write to open writeable Filehandle

by hipowls (Curate)
on May 09, 2008 at 12:09 UTC ( [id://685645]=note: print w/replies, xml ) Need Help??


in reply to Can't write to open writeable Filehandle

There is a lot of repetition, most of the if blocks do the same thing and each block repeats its list of headers. And that list of headers it's pretty hard to read. I'd suggest that you look at factoring out much of that duplication. Something like

my %inputfiles = ( gene2accession => join( "\t", qw( Taxon GeneID Status RNA_Nucleotide_Accession RNA_Nucleotide_gi Protein_Accession Protein_gi Genomic_Nucleotide_Accession Genomic_Nucleotide_gi Genomic_Accession_Start_Pos Genomic_Accession_End_Pos Orientation Assembly ) ), gene2go => join( "\t", qw( Taxon GeneID GO_ID Evidence Qualifier GO_term PubMedID Category ) ), ... ); foreach my $file ( keys %inputfiles ) { ... while ( my $line = <INPUT> ) { if ( $linecount == 0 ) { print OUTFILE "$file\n"; print SUMMARY "Field lengths for file $file\n"; print SUMMARY "$inputfiles{$file}\n"; if ( $file eq 'hiv_interactions' ) { # do special processing } } } ... }
seems to be easier to read. It is obvious that the header is the same in both the summary and out files and that hiv_interactions gets special treatment. The headers are also easier to read. At least something to consider for your next script;)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-26 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found