I'd like to start this reply with saying that I might be completely wrong. I merely try to state why I think it works the way it works.
when it's clear right in the beginning that this isn't going to lead to any new conclusions with respect to the existence of the final key
Is it, though? If you see operators as functions with funny syntax (which is what operators are), you could say that the underlying function for -> is deref(HASHREF, KEY). Having that established, it is of importance to note that normal rules of precedence
So the simple case of exists $hashRef->{key1}->{key2} boils down to
exists(
deref(
deref(
$hashRef,
"key1"
),
"key2"
)
)
Considering the order of precedence, the very first call that is made, is the innermost thing: deref($hashRef, "key1"). It would be weird if, at this point, perl would break in and said, wait! Before we're doing anything, let's find out why we're doing it anyway! and would analyze the whole statement to see if it's doing an assignment or simply an exists/defined check.
Is it really worth the hassle? Or is it simpler to just learn the side effect of the -> operator?
| [reply] [d/l] [select] |