in reply to "Backing up" a subroutine during runtime.
Yep. This is truly an amazing feature of Perl.
I once did a similar thing with an IRC robot. It had various handlers that were triggered based on regexps matching things passing in a channel.
Without taking down the bot, I could edit the code of a particular handler on the server, and then connect to the channel, send a sekret™ private message to the bot, which would instruct it to reload the handler code, save the old code onto an array of coderefs attached to the trigger regexp, and install the new code in its place.
If the code failed to evaluate, it wouldn't get installed. If the new code ran for a while and I didn't like what it did, I could send another message to tell the bot to throw away the new version of the code and reinstate the version N-1.
I thought it was incredibly cool to be able to undo code changes, and have always kept it in the back of my mind hoping I'd be able to put it to use in Real Life sometime.
• another intruder with the mooring in the heart of the Perl