in reply to puzzling behaviour of keys function
Autovivification. It's not the third line that causes the key to appear in the hash, but the second. The keys function is just letting you know that it's there.
duff