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