G'day Joe

It'd be nice to have a little more data. I think your __DIE__ handler is a great idea, but it's obviously not showing up the error. I can't tell you why. It looks like your code is getting a warning for no reason, but I can't tell you why that is so.

I have occasionally got HASH reference errors for nothing to do with hashes before and it's usually because I've forgotten to close some quotes or put in a semi-colon or whatever.

Nevertheless, I'm curious what your code returns for the following (just drop this in place of the segment you cut'n'pasted for us above):

use Data::Dumper; # Just grabbing the values of these so that # strict will cope with them. my $my_today_int = $today_int; my $my_no_call_requested_days = $no_call_requested_days; my $my_i = $i; my $my_user_id = $user_id; print STDERR Dumper($my_today_int, $my_i, $my_user_id); print STDERR Dumper($my_no_call_requested_days); { use strict; my @today = @{$my_no_call_requested_days->{$my_today_int}}; print STDERR "today:\n", Dumper(@today); my $ref = $today[$my_i]; print STDERR "ref:\n", Dumper($ref); my $employee_id = $ref->{'employee_id'}; print STDERR "employee_id: [$employee_id]\n"; if($employee_id eq $my_user_id) # should be "==" { print "They are the same!\n"; } }
It's functionally the same. This block is strict compliant and all the interesting values are printed to STDERR so that we can see things as they go on.

Hopefully rewriting to something like this will help identify the problem. Particularly if the bug is a missing close quote or } or similar above. :)

Hope it helps.

jarich


In reply to Re: Can't use an undefined value as a HASH reference by jarich
in thread Can't use an undefined value as a HASH reference 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!
  • 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.