in reply to Trapping a Function Call in Non-OO Perl

Or, if you can't edit the other file for some reason, you could mess with its symbol table. No need for OO.

*OtherPackage::exit_function = *MyPackage::do_what_I_want;

dave hj~

Replies are listed 'Best First'.
Just cause you can doesn't mean you should!
by dragonchild (Archbishop) on Feb 15, 2002 at 15:50 UTC
    I would add that this is a MAJOR action, this messing with someone else's symbol table. This is something that should be done as an ultimate last resort, with great trepidation. If you're considering doing this, you should probably just write your own version of said file.

    The reasoning is this:

    1. I can't edit the file I want to edit.
    2. This means I probably don't completely comprehend said file.
    3. I'm making a change in something the file assumes will not be changed.
    4. This means that I don't know what all the ramifications of that are.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      So it was not such a mad idea after all :) Some great ideas here, now I just have to figure out which one to apply.

      BTW, I'd agree wholeheartedly with not messing with the symbol table :)

      Thanks,

      Kakaze