in reply to How to get Pod::Coverage to stop calling my export naked

sub import { # ... { no strict 'refs'; *{$pkg."::DEBUG"} = sub() { $debug }; } # ... }

- tye        

  • Comment on Re: How to get Pod::Coverage to stop calling my export naked (closure)
  • Download Code

Replies are listed 'Best First'.
Re^2: How to get Pod::Coverage to stop calling my export naked (closure)
by Oberon (Monk) on Feb 04, 2012 at 21:28 UTC

    You, sir, are brilliant.

    That was so much simpler than I expected ... thank you so much for the super-quick turnaround.

Re^2: How to get Pod::Coverage to stop calling my export naked (closure)
by tobyink (Canon) on Feb 06, 2012 at 08:37 UTC

    Note that if the module that is importing DEBUG uses namespace::autoclean or similar (as is common in the Moose world these days), then the DEBUG function will not be callable as an object or class method. (Though it should still be called OK as a function.)

    A workaround for that is to use Sub::Name

    use Sub::Name qw/subname/; sub import { # ... my $exp = $pkg."::DEBUG"; { no strict 'refs'; *{$exp} = subname $exp => sub() { $debug }; } # ... }