File Coverage

blib/lib/Devel/CompileLevel.pm
Criterion Covered Total %
statement 31 31 100.0
branch 7 8 87.5
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 48 49 97.9


line stmt bran cond sub pod time code
1             package Devel::CompileLevel;
2 1     1   44597 use strict;
  1         2  
  1         48  
3 1     1   8 use warnings;
  1         1  
  1         51  
4 1     1   7 no warnings 'once';
  1         7  
  1         102  
5              
6             our $VERSION = '0.001002';
7             $VERSION =~ tr/_//d;
8              
9 1     1   7 use Exporter (); BEGIN { *import = \&Exporter::import }
  1     1   2  
  1         44  
  1         74  
10              
11             our @EXPORT_OK = qw(
12             compile_level
13             compile_caller
14             );
15              
16             sub compile_level () {
17 1     1   13 no warnings;
  1         1  
  1         311  
18 15     15 1 775 local ${^WARNING_BITS} = $warnings::NONE;
19 15         23 my $level = 0;
20 15         139 while (my @caller = caller(++$level)) {
21 39         45 my $hints = $caller[9];
22             next
23 39 100       254 if $hints ne ${^WARNING_BITS};
24 11         27 ${^WARNING_BITS} ^= "\x01";
25 11         61 my $newhints = (caller($level))[9];
26 11 50       34 if ($newhints ne $hints) {
27 11         72 return $level - 1;
28             }
29             }
30 4         22 return undef;
31             }
32              
33             sub compile_caller () {
34 8     8 1 1790 my $level = compile_level;
35             return
36 8 100       22 unless defined $level;
37              
38 7 100       23 if (caller eq 'DB') {
39             package
40             DB;
41 1         8 caller($level - 1);
42             }
43             else {
44 6         44 caller($level - 1);
45             }
46             }
47              
48             1;
49              
50             __END__