Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
this is my complete code:

Well, what happened to  $refine =1; ? Where's the  use strict; and the  use Data::Dumper; that others suggested earlier? (In other words, if you think this is the whole script, you're wrong.) When you do this:

while (<LOOKUP>) { ($name, $id) = (split m{\t})[3, 4]; print "id: $id\n"; $data{$file}{$id} = $name; }
is it possible that the "$id" string (fifth tab-delimited field on each line of $file) is at the end of the line? If so, that would mean that there's a "\n" (or "\r\n") included in the value of $id.

If you've already tried chop and chomp to no avail, try this instead:

s/[\r\n]+$//;
That can be handy for cases where you are reading data files that come from some OS other than the one your script is running on. Do that both inside the  while <LOOKUP> loop and inside the  while <dig_go> loop.

Apart from that, if you'll start applying some of the advice you've already been given (use strict, use Data::Dumper), problems will be easier to diagnose, and you should be able to find the problem on your own. You might also want to use the perl debugger (start your script with  perl -d script_file ), set break points inside each of those while loops, and see what's going on (cf. perldebtut and perldebug).

If your script has  use Data::Dumper; , you can say  p Dumper(\%data) as a debugger command, to see what's in your hash structure, as well as just  p to print the current value of $_ (whatever was just read from a file). Very handy, and really simple. Do that.


In reply to Re^3: hash of hashes by graff
in thread hash of hashes by Anonymous Monk

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (7)
    As of 2014-07-29 00:14 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (210 votes), past polls