lib/Scope/UndefSafe.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 20 | 20 | 100.0 |
branch | 2 | 2 | 100.0 |
condition | n/a | ||
subroutine | 6 | 6 | 100.0 |
pod | 2 | 2 | 100.0 |
total | 30 | 30 | 100.0 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Scope::UndefSafe; | ||||||
2 | 3 | 3 | 33507 | use strict; | |||
3 | 3 | ||||||
3 | 72 | ||||||
3 | 3 | 3 | 11 | use warnings; | |||
3 | 3 | ||||||
3 | 58 | ||||||
4 | 3 | 3 | 14 | use utf8; | |||
3 | 2 | ||||||
3 | 15 | ||||||
5 | |||||||
6 | our $VERSION = "0.03"; | ||||||
7 | |||||||
8 | 3 | 3 | 99 | use Exporter qw/import/; | |||
3 | 17 | ||||||
3 | 353 | ||||||
9 | our @EXPORT_OK = qw/let apply/; | ||||||
10 | |||||||
11 | sub let (&$; &) { | ||||||
12 | 18 | 18 | 1 | 7280 | my ($func, $value) = @_; | ||
13 | |||||||
14 | 18 | 100 | 37 | if (defined $value) { | |||
15 | 16 | 17 | local $_ = $value; | ||||
16 | 16 | 27 | return $func->(); | ||||
17 | } | ||||||
18 | |||||||
19 | 2 | 3 | return undef; | ||||
20 | } | ||||||
21 | |||||||
22 | sub apply (&$; &) { | ||||||
23 | 9 | 9 | 1 | 5309 | my ($func, $value) = @_; | ||
24 | 9 | 18 | let(\&$func, $value); | ||||
25 | 9 | 1973 | return $value; | ||||
26 | } | ||||||
27 | |||||||
28 | 1; | ||||||
29 | __END__ |