| 1 | 2 | ▶ | use 5.006; | ||||||||
|
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 Attribute::SubName; | ||||||||||
| 6 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | $Attribute::SubName::VERSION = '1.101420'; | |||||||||
| 8 | } | ||||||||||
| 9 | # ABSTRACT: Naming anonymous subroutines via attributes | ||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | use Sub::Name; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use parent 'Attribute::Handlers'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | sub UNIVERSAL::Name : ATTR(CODE) { | ||||||||
|
Subroutine
Name: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 15 | 1 | my ($package, $symbol, $referent, $attr, $data, $phase) = @_; | |||||||||
| 16 | 1 | ▶ | $data = [$data] unless ref $data eq 'ARRAY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 1 | for my $item (@$data) { | |||||||||
| 18 | 1 | my $name = "${package}::${item}"; | |||||||||
| 19 | 1 | subname $name => $referent; | |||||||||
| 20 | 2 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | *{$name} = $referent; | |||||||||
| 22 | } | ||||||||||
| 23 | 2 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 2 | 1; | |||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | __END__ | ||||||||||