in reply to Errors with sorting hashs

To debug this, I would take the following steps:
  1. Have your script print out the line it's looking at
  2. Add use warnings FATAL => qw( uninitialized numeric ); to the top of your script.
  3. Have it run. When it hits the naughty line in your log, it will print it out, then die, so the last line printed will be an example naughty-doer.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

Replies are listed 'Best First'.
Re^2: Errors with sorting hashs
by red-beard (Scribe) on Aug 27, 2004 at 14:02 UTC

    I'm getting the following when I do that.


    65.207.129.252 sent the following virus's a total of 16 times:

    Use of uninitialized value in numeric comparison (<=>) at

    ./source_virus_count.pl line 70 (#1)

    (W uninitialized) An undefined value was used as if it were already defined. It was interpreted as a "" or a 0, but maybe it was a mistake.

    To suppress this warning assign a defined value to your variables.

    To help you figure out what was undefined, perl tells you what operation you used the undefined value in. Note, however, that perl optimizes your program and the operation displayed in the warning may not necessarily appear literally in your program. For example, "that $foo" is usually optimized into "that " . $foo, and the warning will refer to the concatenation (.) operator, even though there is no . in your program.

    Uncaught exception from user code:

    Use of uninitialized value in numeric comparison (<=>) at ./source_virus_count.pl line 70.

    main::hashValueDescendingVirus called at ./source_virus_count.pl line 99

      Ok. You know the line that's causing a problem. Have you traced how that line moves through your program? Have you added print statements that tell you what's going on? What work have you done, given the new information?

      I'm not going to debug your program for you. I give advice. If you want work, I can give you my PayPal account to deposit $$ into.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      I shouldn't have to say this, but any code, unless otherwise stated, is untested

        I figured it out!!! I had declared the $ip_addr and $sender as a my and it should have been an our.
        my $ip_addr; my $sender;
        to
        our $ip_addr; our $sender;
      I used Data::Dumper to show what was happening on lines 70 and 99.

      It looks like my subroutine is not getting the correct values. For example everything from the ip address till $VAR4 is correct. However my numeric comparison for $VAR4 is showing values from the $VAR2 comparison.

      66.118.133.154 sent the following virus's a total of 19 times: $VAR1 = \{ 'sender' => { 'jdillon@karaco.com' => 1, '0000774243@nocmailsvc001.allthesites.org' = +> 1, 'se56092d.098@gwia.ci.tampa.fl.us' => 1, 'owner@zedo[2].txt' => 1, 'pobonline-feedback-138@lb.bcentral.com' => +1, 'al464718@aol.com' => 1, 'info@ebsengineering.com' => 1, 'abuse@gov.us' => 1, 'bids@enviro-logical.com' => 1, 'postmaster@ussurveyor.com' => 1, 'mmeyers@innet.com' => 1, 'rjnickson@netzero.net' => 1, 'owner@advertising[1].txt' => 1, 'fraysier@tds.net' => 1, 'dopicoproperties@msn.com' => 1, 'hussdrilling@earthlink.net' => 1, 'affiliatedsupply@hotmail.com' => 1, 's706moss@earthlink.net' => 1, 'arnolde@hillsboroughcounty.org' => 1 }, 'virus' => { 'Worm.SomeFool.P Intercepted' => 3, 'Worm.SomeFool.PIntercepted' => 16 } }; $VAR2 = \{ 'Worm.SomeFool.P Intercepted' => 3, 'Worm.SomeFool.PIntercepted' => 16 }; 65.207.129.252 sent the following virus's a total of 16 times: $VAR3 = \{ 'sender' => { 'c@0ie.ee' => 1, 'damian.sandoval@brooks.af.mil' => 1, 'ybev_@[ecxab.7' => 1, 'bp-es0es0cq.@n' => 1, 'e75@0.9' => 1, 'gb.f@5' => 1, 'ammer@langley.af.mil' => 1, 'bill_dougherty@urscorp.com' => 1, 'fl.@k.' => 1, '_c@ntriomin.gn-' => 1, '7k@7f9.c6' => 1, 'pdmeeks@access.mountain.net' => 1, '/ba-c@-da.id.je' => 1, '2/6@0.d' => 1, 'bleiter@huntconstructiongroup.com' => 1, 'e@h1.5' => 1 }, 'virus' => { 'Worm.SomeFool.ZIntercepted' => 7, 'Worm.SomeFool.Z Intercepted' => 9 } }; $VAR4 = \{ 'Worm.SomeFool.P Intercepted' => 3, 'Worm.SomeFool.PIntercepted' => 16 };