in reply to does if(%{$ptr->{key}}) define?
I bet you never would have predicted this when you got up this morning, but you are witnessing a process called autovivification. Basically, when you dereference an undefined value in a context that sssumes it exists, it gets created automatically. In your case:
keys %{$t->{r}}
is the place where the autovivification occurs. You are dereferencing $t as if it were a hashref, so it gets created as a hashref. The same thing happens to $t->{r}, because that gets dereferenced by the keys %{ } construct.
Now, my understanding of autovivification is imperfect, so I might be wrong on the subtleties (or even the big picture) here. Somebody else will pipe in if I am.
You can get more information on autovivification in perlref.
CU
Robartes-
|
|---|