| 1 | package Getopt::ArgParse::Namespace; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 20 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 20 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 20 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 33 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||
| 8 | 33 | my $class = shift; | |||||||||||||||||||
| 9 | 33 | ▶ | my $real_class = ref $class || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 33 | my $self = {}; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 33 | bless $self, $real_class; | |||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 472 | ▶ | sub set_attr { | ||||||||||||||||||
|
Subroutine
set_attr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 17 | 472 | my $self = shift; | |||||||||||||||||||
| 18 | 472 | my ($dest, $values) = @_; | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 472 | $self->{'-values'}{$dest} = $values; | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 799 | ▶ | sub get_attr { | ||||||||||||||||||
|
Subroutine
get_attr: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||
| 24 | 799 | my $self = shift; | |||||||||||||||||||
| 25 | 799 | my ($dest) = @_; | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 799 | ▶ | confess "Must provide $dest" unless $dest; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 799 | ▶ | return $self->{'-values'}{$dest} if exists $self->{'-values'}{$dest}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 204 | return undef; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 20 | our $AUTOLOAD; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 75 | ▶ | sub AUTOLOAD { | ||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=6 SCAR=17.9
| |||||||||||||||||||||
| 37 | 75 | my $sub = $AUTOLOAD; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 75 | (my $dest = $sub) =~ s/.*:://; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 75 | my $self = shift; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 75 | ▶ | if ( exists $self->{'-values'}{$dest} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 74 | my $values = $self->{'-values'}{$dest}; | |||||||||||||||||||
| 45 | 74 | ▶ | if (ref($values) eq 'ARRAY') { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 46 | 14 | ▶ | return wantarray ? @$values : $values; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | } elsif (ref($values) eq 'HASH') { | ||||||||||||||||||||
| 48 | 8 | ▶ | return wantarray ? %$values : $values; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||
| 50 | 52 | return $values; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | } else { | ||||||||||||||||||||
| 53 | 1 | croak "unknown option: $dest"; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | ▶ | sub DESTROY { } | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 20 | 1; | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =head1 AUTHOR | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | Mytram <mytram2@gmail.com> (original author) | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | This software is Copyright (c) 2014 by Mytram. | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | This is free software, licensed under: | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | The Artistic License 2.0 (GPL Compatible) | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||