Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: "Backing up" a subroutine during runtime.

by grinder (Bishop)
on Oct 21, 2008 at 18:17 UTC ( [id://718555]=note: print w/replies, xml ) Need Help??


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

  • Comment on Re: "Backing up" a subroutine during runtime.

Replies are listed 'Best First'.
Re^2: "Backing up" a subroutine during runtime.
by dextius (Monk) on Oct 21, 2008 at 20:49 UTC
    That is exactly what our code does. The ruby guys in my office were going on about how this is such a well covered tactic in their world. I wasn't out to prove them wrong, I just needed the equivalent functionality. I'm glad I found it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://718555]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-23 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found