File Coverage

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   119306 use strict;
  3         14  
  3         67  
3 3     3   10 use warnings;
  3         5  
  3         57  
4 3     3   10 use utf8;
  3         4  
  3         11  
5              
6             our $VERSION = "0.04";
7              
8 3     3   123 use Exporter qw/import/;
  3         3  
  3         403  
9             our @EXPORT_OK = qw/let apply/;
10              
11             sub let (&$; &) {
12 18     18 1 15440 my ($func, $value) = @_;
13              
14 18 100       39 if (defined $value) {
15 16         19 local $_ = $value;
16 16         26 return $func->();
17             }
18              
19 2         3 return undef;
20             }
21              
22             sub apply (&$; &) {
23 9     9 1 12214 my ($func, $value) = @_;
24 9         17 let(\&$func, $value);
25 9         4039 return $value;
26             }
27              
28             1;
29             __END__