File Coverage

blib/script/unsafe-rename
Criterion Covered Total %
statement 28 29 96.5
branch 9 16 56.2
condition n/a
subroutine 6 6 100.0
pod n/a
total 43 51 84.3


line stmt bran cond sub pod time code
1             #!/usr/local/bin/perl
2 7     7   15784 use strict;
  7         15  
  7         206  
3 7     7   34 use warnings;
  7         10  
  7         193  
4            
5 7     7   3133 use File::Rename qw(:config no_require_order);
  7         15  
  7         44  
6 7     7   4697 use Pod::Usage;
  7         356360  
  7         2809  
7            
8             main() unless caller;
9            
10             sub main {
11 11 50   11   23356 my $options = File::Rename::Options::GetOptions()
12             or pod2usage;
13            
14 11 50       40 pod2usage( -verbose => 0,
15             -exitval => 'NOEXIT',
16             -message => <<'MESSAGE',
17             -u|--unicode argument does not look like an encoding:
18             either give an encoding or put -e as next option
19             MESSAGE
20             ) if File::Rename::Options::bad_encoding($options);
21            
22 11 100       34 mod_version() if $options->{show_version};
23 10 50       25 pod2usage( -verbose => 2 ) if $options->{show_manual};
24 10 50       24 pod2usage( -exitval => 1 ) if $options->{show_help};
25            
26 10 50       56 @ARGV = map {glob} @ARGV if $^O =~ m{Win}msx;
  0         0  
27            
28 10         60 File::Rename::rename(\@ARGV, $options);
29             }
30            
31             sub mod_version {
32 1     1   4 print __FILE__;
33 1         16 my $version = File::Rename->VERSION;
34 1         13 my $opt_ver = File::Rename::Options->VERSION;
35 1         5 print ' using File::Rename version '. $version;
36 1 50       53 if( (eval $opt_ver) < (eval $version) ) {
37 1 50       4 $opt_ver .= '.00' unless $opt_ver =~ m{\.};
38 1         5 print ', File::Rename::Options version '. $opt_ver;
39             }
40             # ignore File::Rename->VERSION
41 1         4 print "\n\n";
42 1         143 exit 0
43             }
44            
45             1;
46            
47             __END__