blib/lib/once.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 28 / 28 CC 2 SCAR 2.5
CC
2
Cov
100%
ONCE
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
↑ Summary
1 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package once;
6 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 $once::VERSION = '1.101420';
8 }
9  
10 # ABSTRACT: Execute code only once throughout the program's lifetime
11 2 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 our @EXPORT = qw(ONCE);
13  
14 48 ▶sub ONCE (&) {
Subroutine ONCE: called CC=2 SCAR=6.9
Pod documented
15 48 my $code = shift;
16 48 our %seen;
17 48 my ($package, $filename, $line) = caller;
18 48 ▶ unless ($seen{"ONCE $package $filename $line"}++) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($once::seen{"ONCE $package $filename $line"}++) 4 44 48
19 4 $code->();
20 }
21 }
22 2 1;
23  
24  
25 __END__
↑ Summary