But it is a bad practice to use a key in hashes without quotes, as in $main::{X}
No, it's not. Some people advise against hash key autoquoting, because its behavior can be confusing to some, but this is still a question of style and preference, not "best practices".
NOTE: I think undef is not a value ...
You've made this same edit to the root node. Please mark all of your updates as such, and also don't duplicate content like this, as it makes the thread confusing to follow (some might reply to one copy of the content and miss replies to the other copy).