| 1 | package enum::prefix; | ||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | our $VERSION = '0.04'; | |||||||||
| 6 | |||||||||||
| 7 | 2 | my $ident = '[^\W_0-9]\w*'; | |||||||||
| 8 | |||||||||||
| 9 | sub import | ||||||||||
| 10 | 2 | ▶ | { | ||||||||
|
Subroutine
import: called CC=4 SCAR=13.9
| |||||||||||
| 11 | 2 | my $class = shift; | |||||||||
| 12 | 2 | my $prefix = shift; | |||||||||
| 13 | 2 | my $name_sub_suffix = shift; | |||||||||
| 14 | 2 | ▶ | @_ or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | 1 | my $pkg = caller() . '::'; | |||||||||
| 17 | |||||||||||
| 18 | 1 | my $index = 0; | |||||||||
| 19 | |||||||||||
| 20 | 1 | my @enum; | |||||||||
| 21 | 2 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 1 | for my $name (@_) | |||||||||
| 23 | { | ||||||||||
| 24 | 3 | ▶ | if ( $name =~ /^$ident$/o ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | { | ||||||||||
| 26 | 3 | my $n = $index; | |||||||||
| 27 | 3 | $index++; | |||||||||
| 28 | 0 | ▶ | *{ $pkg . $prefix . $name } = sub(){ $n }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||
| 29 | 3 | $enum[$n] = $name; | |||||||||
| 30 | } | ||||||||||
| 31 | } | ||||||||||
| 32 | 1 | ▶ | *{$pkg. $prefix . $name_sub_suffix } = sub($) { $enum[ $_[0] ] }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 2 | 1; | |||||||||
| 36 | |||||||||||
| 37 | __END__ | ||||||||||