in reply to $! context behavior

You can tie a variable to a class, and by that give it any behaviour you want.

Have a look at tie.