in reply to "local" side effects

The canonical way of responding to scope at the Perl level (without $^H chicanery) is to return an object that you let fall out of scope at the appropriate time.

So, for example, you'd use something like:

sub TEST_WHICH_HAS_LOG_OUTPUT { my $dummy = $log->capture_log_only_for_this_scope; is(...); }

Have you considered doing something along those lines?

Replies are listed 'Best First'.
Re: Re: "local" side effects
by chromatic (Archbishop) on May 21, 2004 at 18:18 UTC

    I have. It's probably the right approach for Test::MockPackage, though I waffle back and forth on taking a block as an argument as Test::Exception's dies_ok() does.

Re: Re: "local" side effects
by Ovid (Cardinal) on May 21, 2004 at 19:04 UTC

    Duh. Some days I have a brain cramp. That eluded me at first because I don't want a lexically scoped variable, but obviously using that to trigger how the side effect is enabled and destroyed is an easy thing to do. Silly me.

    Cheers,
    Ovid

    New address of my CGI Course.