| 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
| |||||||||||
| 19 | 4 | $code->(); | |||||||||
| 20 | } | ||||||||||
| 21 | } | ||||||||||
| 22 | 2 | 1; | |||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | __END__ | ||||||||||