in reply to Re: Overriding a module that is used by a program I'm testing
in thread Overriding a module that is used by a program I'm testing

Wow! The called program is going to load the module, so pre-empt it by loading it myself! I liked this and used it. Thanks!

As for your warning about how this isn't a proper OO override: noted, but in this particular setting I am aiming for total suppression. In fact I went and condensed your suggestion to the following:

# pre-empt the loading use Proc::Background; { no warnings 'redefine'; *Proc::Background::new = sub {}; }

having realized that my stub of choice was a no-op.

Replies are listed 'Best First'.
Re^3: Overriding a module that is used by a program I'm testing
by 7stud (Deacon) on Dec 10, 2010 at 00:50 UTC

    I don't get how that works. use() isn't require(), that is, won't the test code reload Proc::Background and install its version of Proc::Background::new in the symbol table, overwriting the sub reference you installed in the symbol table for Proc::Background::new?

    edit: Never mind. The following are equivalent:

    use Proc::Background #and BEGIN { require Proc::Background; Proc::Background->import; }

    So the second use/require won't do anything.

    Also, couldn't you simply perform a substituion (s///) on launch_rockets.pl and delete the offending lines?