O wise and benevolent masters, I humbly lay my unworthy question at your feet:

My module exports a compile-time constant to its caller. It's important that it be a compile-time constant so the optimizer can take advantage of that. So I create it thusly (in my import):

eval "sub ${caller_package}::DEBUG () { $debug_value }";

The problem is that now Pod::Coverage calls DEBUG a naked subroutine in the caller, which of course fails the ubiquitous Test::Pod::Coverage tests. I decided to look and see how Pod::Coverage was figuring out whether a sub was imported or not, and discovered this bit of Black Magic:

# see if said method wasn't just imported from elsewhere my $glob = do { no strict 'refs'; \*{$sym} }; my $o = B::svref_2object($glob); # in 5.005 this flag is not exposed via B, though it exists my $imported_cv = eval { B::GVf_IMPORTED_CV() } || 0x80; next if $o->GvFLAGS & $imported_cv;

After my head stopped hurting, I decided to just give up and change my code so it really is imported, like so:

eval "sub DEBUG () { $debug_value }"; *{ join('::', $caller_package, 'DEBUG') } = \&DEBUG;

Sure enough, that shuts up Pod::Coverage, but now my compile-time constant isn't a compile-time constant any more. :-/

Now, obviously I know that I can just tell Test::Pod::Coverage to ignore that routine, but I don't think it's reasonable to tell anyone who uses my module to do so. I'm willing to set that bitflag that Pod::Coverage is relying on manually, but I have no idea how to go about that ... that's perlguts stuff, which is a bit beyond my skill level (although I'm willing to attempt it, if anyone could point me in the right direction).

Any thoughts on the best way to get Pod::Coverage to ignore my routine when it's exported to other packages?


In reply to How to get Pod::Coverage to stop calling my export naked by Oberon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.