lamprecht has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

for code like this:

use strict; use warnings; package MyClass; my $anon = sub{ print "this is anonymous called on: $_[0]\n"; }; sub calc{ #$anon->('TEST'); } calc(); 1;

I get 100% sub coverage when required from another script but 75% sub coverage when called stand alone.

The HTML page generated by cover does not mark the lines 5-7 at all in the first case.


Thanks for any insight / workarounds
Christoph

update: wrapping the assignment to  $anon with a  BEGIN block does the trick ...