| 1 | package Sub::Exception; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | our $VERSION = '0.01'; | |||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||
| 8 | 1 | my ($class, %args) = @_; | |||||||||
| 9 | |||||||||||
| 10 | 1 | my $caller = caller; | |||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | while (my ($fn, $handler) = each %args) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | 2 | $class->export( | |||||||||
| 14 | name => $fn, | ||||||||||
| 15 | error_handler => $handler, | ||||||||||
| 16 | package => $caller, | ||||||||||
| 17 | ); | ||||||||||
| 18 | } | ||||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 2 | ▶ | sub export { | ||||||||
|
Subroutine
export: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 2 | my ($class, %args) = @_; | |||||||||
| 23 | |||||||||||
| 24 | 2 | my $name = $args{name}; | |||||||||
| 25 | my $error_handler = $args{error_handler}, | ||||||||||
| 26 | 2 | my $pkg = $args{package}; | |||||||||
| 27 | |||||||||||
| 28 | 1 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 2 | ▶ | *{"$pkg\::$name"} = sub (&) { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||
| 30 | 2 | my ($sub) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 2 | eval { | |||||||||
| 33 | 2 | $sub->(); | |||||||||
| 34 | }; | ||||||||||
| 35 | 2 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 2 | $error_handler->($_ = $@); | |||||||||
| 37 | } | ||||||||||
| 38 | 2 | }; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | 1; | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||