File Coverage

blib/lib/App/FileTools/BulkRename/Common.pm
Criterion Covered Total %
statement 17 17 100.0
branch 4 4 100.0
condition 2 3 66.6
subroutine 6 6 100.0
pod 0 1 0.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package App::FileTools::BulkRename::Common;
2             # ABSTRACT: Common routines needed by the BulkRename user functions
3 1     1   4 use strict;
  1         2  
  1         30  
4 1     1   5 use warnings;
  1         1  
  1         44  
5              
6             BEGIN
7 1     1   48 { our $VERSION = substr '$$Version: 0.07 $$', 11, -3; }
8              
9             require Exporter;
10              
11             our @ISA = qw(Exporter);
12             our @EXPORT_OK=qw(modifiable);
13              
14 1     1   5 use Contextual::Return;
  1         2  
  1         6  
15 1     1   234 use Scalar::Util qw(readonly);
  1         2  
  1         132  
16              
17             # modifiable: return an lvalue which is the first of its input
18             # variables that is both defined, and modifiable.
19             sub modifiable : lvalue
20 30     30 0 47 { my $m=-1;
21              
22 30         72 for my $i (0..$#_)
23 32 100 66     271 { ($m = $i, last) if defined $_[$i] && !readonly $_[$i]; }
24 30 100       195 $m >= 0 ? $_[$m] : $_;
25             }
26              
27             1;