<?xml version="1.0" encoding="windows-1252"?>
<node id="727583" title="Re: Make my script faster and more efficient" created="2008-12-02 22:35:49" updated="2008-12-02 22:35:49">
<type id="11">
note</type>
<author id="460541">
monarch</author>
<data>
<field name="doctext">
I can't help but thinking your inner loop is unnecessary. You're scanning through your list of mappings until you find the one for the current line. But you're missing the beauty of hashes - direct access to the value you want..

&lt;p&gt;Consider this:&lt;code&gt;
  while (&lt;INPUT2&gt;) {
    $_ =~ s/[\r\n]+\z//s; # I don't use chomp, sorry

    my ( $bioC, $contig_id, $pip ) = split( "\t", $_ );
    my $origin = $origins{$contig_id};
    print RESULTS "$bioC\t$origin\t$pip\n";
  }
&lt;/code&gt;

&lt;p&gt;Update: you could also DIE with an error message in the event that the file contained a code that wasn't in your mapping table:&lt;code&gt;
  my $origin = $origins{$contig_id};
  if ( ! defined( $origin ) ) {
    die( "No mapping for \"$contig_id\" found in origins table" );
  }
&lt;/code&gt;</field>
<field name="root_node">
727578</field>
<field name="parent_node">
727578</field>
</data>
</node>
