As mentioned in the previous reply, if you're getting a bunch of "uninitialized variable" warnings, it's probably because the second file you're reading from doesn't have the kind of content that you're expecting on some (or any?) lines.

By the way, understand that "uninitialized" is a warning, not an error. Because you have use warnings; in your script (which is good), you are learning about things that are simply not going as expected; the script continues to run, and empty strings are being printed where you might be expecting non-empty strings. Given that this is the case, try to figure out where your expectations are not being met.

Here's a modified version of the OP script, reformatted to be more compact (and "more perlish") - note how I'm adding some lines to check for unexpected conditions, and report them:

#!/usr/bin/perl use strict; use warnings; use diagnostics; my %geneSymbolConversion; my $input1 = '/scratch/Drosophila/fb_synonym_fb_2014_05.tsv'; open(INF1,"<", $input1 ) or die "$input1: $!\n"; while (<INF1>){ chomp; if ( /^FBgn\d+/ ) { my @fields = split "\t"; $geneSymbolConversion{ $fields[0] } = $fields[1]; } } warn sprintf( "loaded %d gene symbols from %s\n", scalar keys %geneSym +bolConversion, $input1 ); my $input2 = '/scratch/Drosophila/FlyRNAi_data_baseline_vs_EGF.txt'; open(INF2,"<", $input2) or die "$input2: $!\n"; open(OUTF1,">",'FLYRNAi_data_baseline_vs_EGFSymbol.txt') or die $!; while (<INF2>) { chomp; my ($geneID, $EGF_Base, $EGF_Stimulus) = split "\t"; if ( $geneID and $EGF_Base and $EGF_Stimulus ) { my $geneSymbol = $geneSymbolConversion{$geneID} || 'NA'; print OUTF1 join("\t", $geneID, $geneSymbol, $EGF_Base, $EGF_S +timulus), "\n"; } else { warn "$input2: line $.: incomplete data: $_\n"; } }
Also, I added "use strict", and re-arranged things so that declarations of variables are placed closer to where the variables are actually used.

(UPDATE: I added a bit more to report how many gene symbols were loaded from the first input, just in case that's informative.)


In reply to Re: Uninitialized Value Hash Lookup Gene Symbol by graff
in thread Uninitialized Value Hash Lookup Gene Symbol by Ch1ralS0ul

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.