in reply to Capturing mouse and keyboard events
You might want to take a look at XMacro. It has most of your described functionality already, though not in Perl. Well, can't have everything ;-)
"A chicken is an egg's way of producing more eggs."