It is difficult for me to reproduce your problem because your code is not generalized in any way. I do not have Lotus Notes. However I have run into this error many times. I recently read a wonderful suggestion to safequard against this error.

First suggestion is to turn on warnings and diagnostics for testing. This shows you as much information about your error as possible.{leave the strict pragma on!}

use warnings; use diagnostics;

So here is an simple example of the error:

use strict; use warnings; use diagnostics; my $href; my %hash; %hash = %{$href}; --Error-- Can't use an undefined value as a HASH reference at line 8 (#1) (F) A value used as either a hard reference or a symbolic referenc +e must be a defined value. This helps to delurk some insidious errors. Uncaught exception from user code: Can't use an undefined value as a HASH reference at line 8.

You can not deference a reference that is not defined. But you can deference a reference to an empty object. Like this:

use strict; use warnings; use diagnostics; my $href = {}; my %hash; %hash = %{$href}; --Error-- This caused no error

And here is the wonderful suggestion I read in the Effective Perl Programming Book p.125 by Hall with merlyn. If you can't intialize your hash reference, have the expression default to an empty anonymous hash reference. Like this:

use strict; use warnings; use diagnostics; my $href; my %hash; %hash = %{$href || {}}; --Error-- This caused no error also

I apologize if this comment was too general and was not helpful in solving your problem

Man I love that book!

-DeaconBlues

In reply to Re: Hash problem. by DeaconBlues
in thread Hash problem. 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.