in reply to tie and magic
I think XML::Smart works like this (except that the variable is not readonly).
Updated:fixed the link