| 1 | package File::Rename::Options; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 14 | ▶ | BEGIN { eval { require warnings; warnings->import } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use Getopt::Long (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 14 | our $VERSION = '1.90'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 14 | our $IMPORTED; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | sub import { | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 14 | ▶ | my $pack = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 14 | ▶ | if( $IMPORTED++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | Carp::cluck("$pack->import() called twice"); | |||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 14 | my @config = qw( | |||||||||||||||||||||||||||||||||||||||||
| 18 | posix_default | ||||||||||||||||||||||||||||||||||||||||||
| 19 | no_ignore_case | ||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 14 | push @config, @_; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 14 | eval{ Getopt::Long::Configure(@config); 1; } | |||||||||||||||||||||||||||||||||||||||||
| 23 | 14 | ▶ | or do { require Carp; Carp::carp($@) }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | sub GetOptions { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 18 | ▶ | my ($no_code) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetOptions: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 18 | my @expression; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 18 | my $fullpath = 1; | |||||||||||||||||||||||||||||||||||||||||
| 30 | Getopt::Long::GetOptions( | ||||||||||||||||||||||||||||||||||||||||||
| 31 | '-v|verbose' => \my $verbose, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | '-0|null' => \my $null, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | '-n|nono' => \my $nono, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | '-f|force' => \my $force, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | '-h|?|help' => \my $help, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | '-m|man' => \my $man, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | '-V|version' => \my $version, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | '-d|filename' => sub { undef $fullpath }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | '-path|fullpath!' => \$fullpath, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | '-e=s' => \@expression, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | '-E=s' => | ||||||||||||||||||||||||||||||||||||||||||
| 42 | sub { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | ▶ | my(undef, $e) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 4 | $e .= ';'; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | push @expression, $e; | |||||||||||||||||||||||||||||||||||||||||
| 46 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 18 | ▶ | '-u|unicode:s' => \my $unicode, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | ) or return; | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 18 | my $options = { | |||||||||||||||||||||||||||||||||||||||||
| 51 | verbose => $verbose, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | input_null => $null, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | no_action => $nono, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | over_write => $force, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | filename_only => !$fullpath, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | show_help => $help, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | show_manual => $man, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | show_version => $version, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | unicode_strings => defined $unicode, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | encoding => $unicode, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 18 | ▶ | return $options if $no_code; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 12 | ▶ | return $options if $help or $man or $version; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$help or $man or $version
$help or $man
MC/DC33%1/3
$help or $man or $version
$help
$man
$version
Truth table50%2/4
A or B or C
A= $helpB= $manC= $version
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 11 | ▶ | if( @expression ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | $options->{_code} = join "\n", @expression; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 8 | ▶ | return unless @ARGV; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 8 | $options->{_code} = shift @ARGV; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 11 | return $options; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | sub bad_encoding { | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 10 | ▶ | my $options = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bad_encoding: called CC=3 SCAR=15.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 10 | my $encoding = $options->{encoding}; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 10 | ▶ | return unless $encoding; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | return unless $encoding =~ /[^\s\w.-]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return 1 | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||||||||||||||||