File Coverage

blib/lib/Sub/ArgShortcut.pm
Criterion Covered Total %
statement 23 23 100.0
branch 9 10 90.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 40 41 97.5


line stmt bran cond sub pod time code
1 2     2   57335 use 5.006; use strict; use warnings;
  2     2   18  
  2     2   10  
  2         3  
  2         54  
  2         10  
  2         4  
  2         367  
2              
3             package Sub::ArgShortcut;
4              
5             our $VERSION = '1.022';
6              
7             sub argshortcut(&) {
8 2     2 1 75 my ( $code ) = @_;
9             return sub {
10 8     8   5443 my @byval;
11 8         14 my $nondestructive = defined wantarray;
12 8 100       48 $code->(
    100          
    100          
13             $nondestructive
14             ? ( @byval = @_ ? @_ : $_ )
15             : ( @_ ? @_ : $_ )
16             );
17 8 100       58 return $nondestructive ? @byval[ 0 .. $#byval ] : ();
18 2         11 };
19             }
20              
21             sub import {
22 2     2   8 my $class = shift;
23 2         10 my $install_pkg = caller;
24 2 50       7 die q(Something mysterious happened) if not defined $install_pkg;
25 2     2   13 { no strict 'refs'; *{"${install_pkg}::argshortcut"} = \&argshortcut; }
  2         4  
  2         139  
  2         4  
  2         5  
  2         113  
26             }
27              
28             1;
29              
30             __END__