in reply to Re: Blessing interior hashes
in thread Blessing interior hashes

Thanks, ikegami. I'll use that.

I was initially puzzled—what is going inside those eval's? Let me see if I've puzzled it out right:

Right?

throop

Replies are listed 'Best First'.
Re^3: Blessing interior hashes
by ikegami (Patriarch) on Oct 03, 2007 at 18:28 UTC

    Yup, excellent!

    Two little additions:
    || 1 assures a true value when %$ref is an empty hash.
    || 1 avoids the "void context" warning ; 1 would issue.

    One little correction:
    On error, eval returns false (dualvar 0, ""), not undef.

      On error, eval returns false (dualvar 0, ""), not undef.

      From perlfunc:

      If there is a syntax error or runtime error, or a die statement is executed, an undefined value is returned by eval

      lodin

        I had tested with the following. Note the lack of warning

        >perl -wle"$r=[]; print eval { %$r || 1 }

        Turns out we're both wrong. eval returns an empty list.

        >perl -wle"$r=[]; print scalar(() = eval { %$r || 1 }); 0

        An empty list is interpreted as undef in scalar context.