in reply to Re^7: Why does exists cause autovivication?
in thread Why does exists cause autovivication?

Okay, so is my original example:
next unless exists $user_by_uid{$uid}->{$host};

more like the following:

$href = defined $user_by_uid{$uid} ? $user_by_uid{$uid} : {}; #Fake au +toviv next unless exists $href->{$host};

Or would it be more like the following, using your example code?

next unless my_fake_exists $user_by_uid{$uid}, $host;

In other words, since there is no short-circuit evaluation to avoid the -> in my original example does that mean the autoviv occurs before anything is passed in to 'exists'?

Thanks very much for taking time to respond and hope you had a Happy New Year!!

Replies are listed 'Best First'.
Re^9: Why does exists cause autovivication?
by shmem (Chancellor) on Jan 02, 2008 at 21:31 UTC
    No need to autovivify anything, only to test an empty hashref for a non-existent key.
    next unless exists $user_by_uid{$uid}; next unless exists $user_by_uid{$uid}->{$host};

    should do.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}