| 1 | package JSON::Path::Evaluator; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 20 | $JSON::Path::Evaluator::VERSION = '1.0.6'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: A module that recursively evaluates JSONPath expressions with native support for Javascript-style filters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 20 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 20 | ▶ | use Carp::Assert qw(assert); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 20 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 20 | ▶ | use JSON::Path::Constants qw(:operators :symbols); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 20 | ▶ | use JSON::Path::Tokenizer qw(tokenize); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 20 | ▶ | use List::Util qw/pairs uniq/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 20 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 20 | ▶ | use Safe; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 20 | ▶ | use Scalar::Util qw/looks_like_number blessed refaddr/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 20 | ▶ | use Storable qw/dclone/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 20 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 20 | ▶ | use Exporter::Shiny qw/evaluate_jsonpath/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 20 | our $AUTHORITY = 'cpan:POPEFELIX'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 20 | Readonly my $OPERATOR_IS_TRUE => 'IS_TRUE'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 20 | Readonly my $OPERATOR_TYPE_PATH => 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 20 | Readonly my $OPERATOR_TYPE_COMPARISON => 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 20 | Readonly my %OPERATORS => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $TOKEN_ROOT => $OPERATOR_TYPE_PATH, # $ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | $TOKEN_CURRENT => $OPERATOR_TYPE_PATH, # @ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | $TOKEN_CHILD => $OPERATOR_TYPE_PATH, # . OR [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | $TOKEN_RECURSIVE => $OPERATOR_TYPE_PATH, # .. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | $TOKEN_ALL => $OPERATOR_TYPE_PATH, # * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | $TOKEN_FILTER_OPEN => $OPERATOR_TYPE_PATH, # ?( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | $TOKEN_SCRIPT_OPEN => $OPERATOR_TYPE_PATH, # ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | $TOKEN_FILTER_SCRIPT_CLOSE => $OPERATOR_TYPE_PATH, # ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $TOKEN_SUBSCRIPT_OPEN => $OPERATOR_TYPE_PATH, # [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $TOKEN_SUBSCRIPT_CLOSE => $OPERATOR_TYPE_PATH, # ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $TOKEN_UNION => $OPERATOR_TYPE_PATH, # , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | $TOKEN_ARRAY_SLICE => $OPERATOR_TYPE_PATH, # [ start:end:step ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | $TOKEN_SINGLE_EQUAL => $OPERATOR_TYPE_COMPARISON, # = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | $TOKEN_DOUBLE_EQUAL => $OPERATOR_TYPE_COMPARISON, # == | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | $TOKEN_TRIPLE_EQUAL => $OPERATOR_TYPE_COMPARISON, # === | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | $TOKEN_GREATER_THAN => $OPERATOR_TYPE_COMPARISON, # > | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | $TOKEN_LESS_THAN => $OPERATOR_TYPE_COMPARISON, # < | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | $TOKEN_NOT_EQUAL => $OPERATOR_TYPE_COMPARISON, # != | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | $TOKEN_GREATER_EQUAL => $OPERATOR_TYPE_COMPARISON, # >= | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | $TOKEN_LESS_EQUAL => $OPERATOR_TYPE_COMPARISON, # <= | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $TOKEN_REGEX => $OPERATOR_TYPE_COMPARISON, # =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 20 | Readonly my $ASSERT_ENABLE => $ENV{ASSERT_ENABLE}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 147 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=22.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 147 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my %args = ref $_[0] eq 'HASH' ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 147 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 147 | for my $key (qw/root expression/) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 294 | ▶ | croak qq{Missing required argument '$key' in constructor} unless $args{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 294 | $self->{$key} = $args{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 147 | ▶ | $self->{want_ref} = $args{want_ref} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'want_ref'} || 0
MC/DC0%0/1
$args{'want_ref'} || 0
$args{'want_ref'}
Truth table50%1/2
A
A= $args{'want_ref'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 147 | ▶ | $self->{_calling_context} = $args{_calling_context} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'_calling_context'} || 0
MC/DC0%0/1
$args{'_calling_context'} || 0
$args{'_calling_context'}
Truth table50%1/2
A
A= $args{'_calling_context'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | my $script_engine = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 147 | ▶ | $args{script_engine} ? $args{script_engine} : $self->{expression} =~ /\$_/ ? 'perl' : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 147 | ▶ | $self->{script_engine} = $script_engine || 'PseudoJS'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$script_engine || 'PseudoJS'
MC/DC100%1/1
$script_engine || 'PseudoJS'
$script_engine
Truth table100%2/2
A
A= $script_engine
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 147 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 147 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 147 | ▶ | sub evaluate_jsonpath { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate_jsonpath: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 147 | my ( $json_object, $expression, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 147 | ▶ | if ( !ref $json_object ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 90 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 90 | $json_object = decode_json($json_object); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | croak qq{Unable to decode $json_object as JSON: $_}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 90 | } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 147 | ▶ | my $want_ref = delete $args{want_ref} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{'want_ref'} || 0
MC/DC100%1/1
delete $args{'want_ref'} || 0
delete $args{'want_ref'}
Truth table100%2/2
A
A= delete $args{'want_ref'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 147 | ▶ | my $want_path = delete $args{want_path} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{'want_path'} || 0
MC/DC100%1/1
delete $args{'want_path'} || 0
delete $args{'want_path'}
Truth table100%2/2
A
A= delete $args{'want_path'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 147 | ▶ | my $self = __PACKAGE__->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | root => $json_object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | expression => $expression, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | _calling_context => wantarray ? 'ARRAY' : 'SCALAR', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | %args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 147 | return $self->evaluate( $expression, want_ref => $want_ref, want_path => $want_path ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 147 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 147 | my ( $self, $expression, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 147 | my $json_object = $self->{root}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 147 | my $token_stream = [ tokenize($expression) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | #use Data::Dumper qw/Dumper/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | #print Dumper $token_stream; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 147 | ▶ | shift @{$token_stream} if $token_stream->[0] eq $TOKEN_ROOT; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 147 | ▶ | shift @{$token_stream} if $token_stream->[0] eq $TOKEN_CHILD; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 147 | ▶ | if ( $args{want_path} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 12 | my %reftable = $self->_reftable_walker($json_object); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 12 | my @refs = $self->_evaluate( $json_object, dclone $token_stream, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 12 | my @paths; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 12 | for my $ref (@refs) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 18 | ▶ | my $refaddr = ref ${$ref} ? refaddr ${$ref} : refaddr $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 18 | push @paths, $reftable{$refaddr}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 12 | return @paths; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 135 | my @ret = $self->_evaluate( $json_object, $token_stream, $args{want_ref} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 135 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 82 | ▶ | sub _reftable_walker { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reftable_walker: called CC=9 SCAR=22.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 82 | my ( $self, $json_object, $base_path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 82 | ▶ | $base_path //= '$'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$base_path //= "\$"
MC/DC100%1/1
$base_path //= "\$"
$base_path
Truth table100%2/2
A
A= $base_path
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 82 | ▶ | $json_object //= $self->root; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$json_object //= $self->root
MC/DC0%0/2
$json_object //= $self->root
$json_object
$self->root
Truth table33%1/3
A //= B
A= $json_objectB= $self->root
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 82 | my @entries = ( refaddr $json_object => $base_path ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 82 | ▶ | if ( _arraylike($json_object) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 9 | for ( 0 .. $#{$json_object} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 33 | my $path = sprintf q{%s['%d']}, $base_path, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 33 | ▶ | if ( ref $json_object->[$_] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 33 | push @entries, $self->_reftable_walker( $json_object->[$_], $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | push @entries, refaddr \( $json_object->[$_] ) => $path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | elsif ( _hashlike($json_object) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 67 | for my $index ( keys %{$json_object} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 241 | my $path = sprintf q{%s['%s']}, $base_path, $index; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 241 | ▶ | if ( ref $json_object->{$index} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 37 | push @entries, $self->_reftable_walker( $json_object->{$index}, $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 204 | push @entries, refaddr \( $json_object->{$index} ) => $path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 82 | return @entries; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 868 | ▶ | sub _evaluate { # This assumes that the token stream is syntactically valid | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_evaluate: called CC=20 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 868 | my ( $self, $obj, $token_stream, $want_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 868 | ▶ | return unless ref $obj; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 784 | ▶ | $token_stream //= []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$token_stream //= []
MC/DC0%0/1
$token_stream //= []
$token_stream
Truth table50%1/2
A
A= $token_stream
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 784 | ▶ | while ( defined( my $token = shift @{$token_stream} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1539 | ▶ | next if $token eq $TOKEN_CURRENT; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1255 | ▶ | next if $token eq $TOKEN_CHILD; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 784 | ▶ | if ( $token eq $TOKEN_FILTER_OPEN ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 73 | my $filter_expression = shift @{$token_stream}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 73 | my $closing_token = shift @{$token_stream}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 73 | ▶ | assert( $closing_token eq $TOKEN_FILTER_SCRIPT_CLOSE, q{Closing token seen} ) if $ASSERT_ENABLE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # Find all indices matching the filter expression. This modifies $token_stream | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 73 | my @matching_indices = $self->_process_filter( $obj, $filter_expression ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 73 | ▶ | if ( !@{$token_stream} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 39 | my @got = map { _get( $obj, $_ ) } @matching_indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 39 | ▶ | return $want_ref ? @got : map { ${$_} } @got; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 34 | return map { $self->_evaluate( _get( $obj, $_ ), dclone($token_stream), $want_ref ) } @matching_indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | elsif ( $token eq $TOKEN_RECURSIVE ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | { # Sweet Jesus, Pooh, that's not honey! You're eating Sweet Jesus, Pooh, that's not honey! You're eating... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 16 | my $index = shift @{$token_stream}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 16 | my @matched; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 16 | ▶ | if ( $index eq $TOKEN_FILTER_OPEN ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | my $filter_expression = shift @{$token_stream}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | my $closing_token = shift @{$token_stream}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | ▶ | assert( $closing_token eq $TOKEN_FILTER_SCRIPT_CLOSE, q{Closing token seen} ) if $ASSERT_ENABLE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | return $self->_filter_recursive( $obj, $filter_expression, $want_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 14 | @matched = _match_recursive( $obj, $index, $want_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 14 | ▶ | if ( !@{$token_stream} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 6 | return @matched; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 8 | return map { $self->_evaluate( $_, dclone($token_stream), $want_ref ) } @matched; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 695 | my $index; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 695 | ▶ | if ( $token eq $TOKEN_SUBSCRIPT_OPEN ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 98 | $index = shift @{$token_stream}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 98 | my $closing_token = shift @{$token_stream}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 98 | ▶ | assert $closing_token eq $TOKEN_SUBSCRIPT_CLOSE if $ASSERT_ENABLE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 597 | $index = $token; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 695 | ▶ | assert( !$OPERATORS{$index}, qq{"$index" is not an operator} ) if $index ne $TOKEN_ALL; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 695 | ▶ | assert( !ref $index, q{Index is a scalar} ) if $ASSERT_ENABLE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 695 | my (@got) = _get( $obj, $index, create_key => $want_ref ); # This always returns a ref | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 695 | ▶ | if ( !@{$token_stream} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 419 | ▶ | return $want_ref ? @got : map { ${$_} } @got; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 276 | return map { $self->_evaluate( ${$_}, dclone($token_stream), $want_ref ) } @got; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 113 | ▶ | sub _process_filter { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_filter: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 113 | my ( $self, $obj, $filter_expression ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 113 | my @matching_indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 113 | ▶ | if ( $self->{script_engine} eq 'PseudoJS' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 106 | @matching_indices = $self->_process_pseudo_js( $obj, $filter_expression ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | elsif ( $self->{script_engine} eq 'perl' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 7 | @matching_indices = $self->_process_perl( $obj, $filter_expression ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | croak qq{Unsupported script engine "$self->{script_engine}"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 113 | return @matching_indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # This _always_ has to return a ref so that when it's called from evaluate( ... , want_ref => 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # So that we can return a ref into the object (e.g. for use as an lvalue), even when the path points | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # to a scalar (which will of course be copied). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # I.E.: for { foo => 'bar' }, we always want \( foo->{bar} ) so that | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # JSON::Path->new('$.foo')->value($obj) = 'baz' works like it oughtta. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 897 | ▶ | sub _get { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get: called CC=16 SCAR=27.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 897 | my ( $object, $index, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 897 | ▶ | assert( _hashlike($object) || _arraylike($object), 'Object is a hashref or an arrayref' ) if $ASSERT_ENABLE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
_hashlike($object) || _arraylike($object)
MC/DC0%0/2
_hashlike($object) || _arraylike($object)
_hashlike($object)
_arraylike($object)
Truth table0%0/3
A || B
A= _hashlike($object)B= _arraylike($object)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 897 | my $create_key = $args{create_key}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # When want_ref is passed to _evaluate(), it will return a reference to whatever was matched. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # If what was matched is itself a ref (e.g. an arrayref), _evaluate() will return a ref of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # type 'REF'. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 897 | ▶ | if ( ref $object eq 'REF' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 32 | $object = ${$object}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 897 | ▶ | if ( $index eq $TOKEN_ALL ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 29 | ▶ | if ( _hashlike($object) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | return map { \($_) } values %{$object}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 26 | return map { \($_) } @{$object}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 868 | my @indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 868 | ▶ | if ( $index =~ /$TOKEN_ARRAY_SLICE/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | my $length = _hashlike($object) ? scalar values %{$object} : scalar @{$object}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 9 | @indices = _slice( $index, $length ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | elsif ( $index =~ /$TOKEN_UNION/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 5 | @indices = split /$TOKEN_UNION/, $index; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 854 | @indices = ($index); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 868 | ▶ | if ( _hashlike($object) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 689 | ▶ | if ($create_key) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 85 | return map { \( $object->{$_} ) } @indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 604 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 604 | for my $index (@indices) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 605 | ▶ | push @ret, \( $object->{$index} ) if exists $object->{$index}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 604 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 179 | my @numeric_indices = grep { looks_like_number($_) } @indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 179 | ▶ | if ($create_key) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 18 | return map { \( $object->[$_] ) } @numeric_indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 161 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 161 | for my $index (@numeric_indices) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 152 | ▶ | push @ret, \( $object->[$index] ) if exists $object->[$index]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 161 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 40 | ▶ | sub _indices { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_indices: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 40 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 27 | ▶ | _hashlike($object) ? keys %{$object} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 40 | ▶ | : _arraylike($object) ? ( 0 .. $#{$object} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 1366 | ▶ | sub _hashlike { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hashlike: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 1366 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1366 | ▶ | return ( ref $object eq 'HASH' || ( blessed $object && $object->can('typeof') && $object->typeof eq 'HASH' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition55%5/9
ref $object eq 'HASH' || builtin::blessed($object) && $object->can('typeof') && $object->typeof eq 'HASH'
builtin::blessed($object) and $object->can("typeof") and $object->typeof eq "HASH"
builtin::blessed($object) and $object->can("typeof")
MC/DC25%1/4
ref $object eq 'HASH' || builtin::blessed($object) && $object->can('typeof') && $object->typeof eq 'HASH'
ref $object eq 'HASH'
builtin::blessed($object)
$object->can("typeof")
$object->typeof eq "HASH"
Truth table60%3/5
A || B and C and D
A= ref $object eq 'HASH'B= builtin::blessed($object)C= $object->can("typeof")D= $object->typeof eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 462 | ▶ | sub _arraylike { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_arraylike: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 462 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 462 | ▶ | return ( ref $object eq 'ARRAY' || ( blessed $object && $object->can('typeof') && $object->typeof eq 'ARRAY' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition55%5/9
ref $object eq 'ARRAY' || builtin::blessed($object) && $object->can('typeof') && $object->typeof eq 'ARRAY'
builtin::blessed($object) and $object->can("typeof") and $object->typeof eq "ARRAY"
builtin::blessed($object) and $object->can("typeof")
MC/DC25%1/4
ref $object eq 'ARRAY' || builtin::blessed($object) && $object->can('typeof') && $object->typeof eq 'ARRAY'
ref $object eq 'ARRAY'
builtin::blessed($object)
$object->can("typeof")
$object->typeof eq "ARRAY"
Truth table60%3/5
A || B and C and D
A= ref $object eq 'ARRAY'B= builtin::blessed($object)C= $object->can("typeof")D= $object->typeof eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | sub _get_token { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_token: not called CC=13 SCAR=49.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $token_stream = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $token = shift @{$token_stream}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | return unless defined $token; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ( $token eq $TOKEN_SUBSCRIPT_OPEN ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my @substream; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | my $close_seen; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | while ( defined( my $token = shift @{$token_stream} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if ( $token eq $TOKEN_SUBSCRIPT_CLOSE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $close_seen = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | push @substream, $token; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | assert($close_seen) if $ASSERT_ENABLE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if ( grep { $_ eq $TOKEN_ARRAY_SLICE } @substream ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # There are five valid cases: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # n:m -> n:m:1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # n:m:s -> n:m:s | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | # :m -> 0:m:1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # ::s -> 0:-1:s | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # n: -> n:-1:1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | if ( $substream[0] eq $TOKEN_ARRAY_SLICE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | unshift @substream, undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 20 | ▶ | no warnings qw/uninitialized/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if ( $substream[2] eq $TOKEN_ARRAY_SLICE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | @substream = ( @substream[ ( 0, 1 ) ], undef, @substream[ ( 2 .. $#substream ) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 20 | ▶ | use warnings qw/uninitialized/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my ( $start, $end, $step ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | $start = $substream[0] // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$substream[0] // 0
MC/DC0%0/1
$substream[0] // 0
$substream[0]
Truth table0%0/2
A
A= $substream[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $end = $substream[2] // -1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$substream[2] // -1
MC/DC0%0/1
$substream[2] // -1
$substream[2]
Truth table0%0/2
A
A= $substream[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | $step = $substream[4] // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$substream[4] // 1
MC/DC0%0/1
$substream[4] // 1
$substream[4]
Truth table0%0/2
A
A= $substream[4]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | return { slice => [ $start, $end, $step ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | elsif ( grep { $_ eq $TOKEN_UNION } @substream ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my @union = grep { $_ ne $TOKEN_UNION } @substream; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return { union => \@union }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | return $substream[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | return $token; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # See http://wiki.ecmascript.org/doku.php?id=proposals:slice_syntax | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # in particular, for the slice [n:m], m is *one greater* than the last index to slice. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # This means that the slice [3:5] will return indices 3 and 4, but *not* 5. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 9 | ▶ | sub _slice { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_slice: called CC=10 SCAR=25.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 9 | my ( $index, $length ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 9 | my ( $start, $end, $step ) = split /$TOKEN_ARRAY_SLICE/, $index, 3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 9 | ▶ | if ( !defined($start) || $start eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $start or $start eq ""
MC/DC0%0/2
not defined $start or $start eq ""
not defined $start
$start eq ""
Truth table33%1/3
not(A) or B
A= not defined $startB= $start eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $start = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 9 | ▶ | if ( !defined($end) || $end eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $end or $end eq ""
MC/DC50%1/2
not defined $end or $end eq ""
not defined $end
$end eq ""
Truth table66%2/3
not(A) or B
A= not defined $endB= $end eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 6 | $end = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 9 | ▶ | if ( !defined($step) || $step eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $step or $step eq ""
MC/DC0%0/2
not defined $step or $step eq ""
not defined $step
$step eq ""
Truth table33%1/3
not(A) or B
A= not defined $stepB= $step eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 9 | $step = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 9 | ▶ | $start = ( $length - 1 ) if $start == -1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 9 | ▶ | $end = $length if $end == -1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 9 | my @indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 9 | ▶ | if ( $step < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | @indices = grep { %_ % -$step == 0 } reverse( $start .. ( $end - 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 9 | @indices = grep { $_ % $step == 0 } ( $start .. ( $end - 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 9 | return @indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 281 | ▶ | sub _match_recursive { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match_recursive: called CC=13 SCAR=26.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 281 | my ( $obj, $index, $want_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 281 | my @match; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # Fix for RT #122529. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # Consider the expression "$..foo..bar", evaluated with respect to the JSON "{"foo":{"bar":"baz"}}". | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # The first term to be evaluated in the expression is "$..foo". If want_ref is passed to evaluate(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # this will return a REF reference. In that case we must first dereference it to get the object that | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # we will evaluate "..bar" with respect to. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 281 | ▶ | if ( ref $obj eq 'REF' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 2 | $obj = ${$obj}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 281 | ▶ | if ( _arraylike($obj) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 82 | ▶ | if ( looks_like_number($index) && exists $obj->[$index] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&looks_like_number($index) and exists $obj->[$index]
MC/DC0%0/2
&looks_like_number($index) and exists $obj->[$index]
&looks_like_number($index)
exists $obj->[$index]
Truth table33%1/3
A and B
A= &looks_like_number($index)B= exists $obj->[$index]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | push @match, $want_ref ? \( $obj->[$index] ) : $obj->[$index]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 82 | for ( 0 .. $#{$obj} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 251 | ▶ | next unless ref $obj->[$_]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 115 | push @match, _match_recursive( $obj->[$_], $index, $want_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | elsif ( _hashlike($obj) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 191 | ▶ | if ( exists $obj->{$index} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 16 | ▶ | push @match, $want_ref ? \( $obj->{$index} ) : $obj->{$index}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 191 | for my $val ( values %{$obj} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 591 | ▶ | next unless ref $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 152 | push @match, _match_recursive( $val, $index, $want_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 281 | return @match; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 40 | ▶ | sub _filter_recursive { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_recursive: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 40 | my ( $self, $obj, $expression, $want_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 40 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # Evaluate the filter expression for the current object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 40 | my @matching_indices = $self->_process_filter( $obj, $expression ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 40 | for my $index (@matching_indices) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 4 | my ($got) = _get( $obj, $index ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 4 | ▶ | push @ret, $want_ref ? $got : ${$got}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # Evaluate the filter expression for any subordinate objects | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 40 | for my $index ( _indices($obj) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 122 | my ($got) = _get( $obj, $index ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 122 | $got = ${$got}; # _get will always return a reference. We want the value, so dereference it | |||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 122 | ▶ | next unless ref $got; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 38 | push @ret, $self->_filter_recursive( $got, $expression, $want_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 40 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 106 | ▶ | sub _process_pseudo_js { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_pseudo_js: called CC=12 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 106 | my ( $self, $object, $expressions ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 106 | my @expressions_or = split /\Q||\E/, $expressions; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 106 | my @matching_or; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 106 | foreach my $expression (@expressions_or) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 117 | my @expressions_and = split /\Q&&\E/, $expression; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 117 | my %matching_and; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 117 | foreach my $expression (@expressions_and) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 141 | my ( $lhs, $operator, $rhs ) = _parse_psuedojs_expression($expression); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 141 | $lhs =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 141 | my (@token_stream) = tokenize($lhs); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 141 | ▶ | if ( _hashlike($object) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 55 | ▶ | while (my ($k, $v) = each(%$object)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 158 | my @got = $self->_evaluate( $v, [@token_stream] ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 158 | foreach my $got (@got) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 56 | ▶ | $matching_and{$k}++ if _compare( $operator, $got, $rhs ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | elsif ( _arraylike($object) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 84 | my $idx = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 84 | for my $value ( @{$object} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 210 | my ($got) = $self->_evaluate( $value, [@token_stream] ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 210 | ▶ | $matching_and{$idx}++ if _compare( $operator, $got, $rhs ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 210 | $idx++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 117 | ▶ | while (my ($idx, $val) = each(%matching_and)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 96 | ▶ | push @matching_or, $idx if ($val == @expressions_and); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 106 | return sort(uniq(@matching_or)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 141 | ▶ | sub _parse_psuedojs_expression { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_psuedojs_expression: called CC=13 SCAR=25.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 141 | my $expression = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 141 | my @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 141 | my ( $lhs, $operator, $rhs ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # The operator could be '=', '!=', '==', '===', '<=', '>=' or '=~' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 141 | ▶ | if ( $expression =~ /$EQUAL_SIGN/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 58 | my $position = index( $expression, '=' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 58 | ▶ | if ( substr( $expression, $position + 1, 1 ) eq $EQUAL_SIGN ) { # could be '==' or '===' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 27 | ▶ | if ( substr( $expression, $position + 2, 1 ) eq $EQUAL_SIGN ) { # === | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | $operator = $TOKEN_TRIPLE_EQUAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 27 | $operator = $TOKEN_DOUBLE_EQUAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | elsif ( substr( $expression, $position + 1, 1 ) eq $TILDE_SIGN ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 18 | $operator = $TOKEN_REGEX; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 13 | my $preceding_char = substr( $expression, $position - 1, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 13 | ▶ | if ( $preceding_char eq $GREATER_THAN_SIGN ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 11 | $operator = $TOKEN_GREATER_EQUAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | elsif ( $preceding_char eq $LESS_THAN_SIGN ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | $operator = $TOKEN_LESS_EQUAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | elsif ( $preceding_char eq $EXCLAMATION_MARK ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | $operator = $TOKEN_NOT_EQUAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 2 | $operator = $TOKEN_SINGLE_EQUAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 58 | ( $lhs, $rhs ) = split /$operator/, $expression, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 83 | for ( grep { $OPERATORS{$_} eq $OPERATOR_TYPE_COMPARISON } keys %OPERATORS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 470 | ▶ | next if /$EQUAL_SIGN/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 149 | ▶ | if ( $expression =~ /$_/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 75 | ( $lhs, $rhs ) = split /$_/, $expression, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 75 | $operator = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 75 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # FIXME: RHS is assumed to be a single value. This isn't necessarily a safe assumption. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 141 | ▶ | if ($operator) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 133 | ▶ | $rhs = _normalize( $rhs || '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$rhs || ''
MC/DC100%1/1
$rhs || ''
$rhs
Truth table100%2/2
A
A= $rhs
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 133 | $lhs = _normalize($lhs); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 8 | $operator = $OPERATOR_IS_TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 8 | $lhs = $expression; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 141 | return ( $lhs, $operator, $rhs ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 266 | ▶ | sub _normalize { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_normalize: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 266 | my $string = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | # NB: Stripping spaces *before* stripping quotes allows the caller to quote spaces in an index. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # So an index of 'foo ' will be correctly normalized as 'foo', but '"foo "' will normalize to 'foo '. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 266 | $string =~ s/\s+$//; # trim trailing spaces | |||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 266 | $string =~ s/^\s+//; # trim leading spaces | |||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 266 | $string =~ s/^['"](.+)['"]$/$1/; # Strip quotes from index | |||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 266 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 7 | ▶ | sub _process_perl { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_perl: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 7 | my ( $self, $object, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 7 | my $cpt = Safe->new; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 7 | $cpt->permit_only( ':base_core', qw/padsv padav padhv padany rv2gv/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 7 | ${ $cpt->varglob('root') } = dclone( $self->{root} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 7 | my @matching; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 7 | ▶ | if ( _hashlike($object) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 2 | for my $index ( keys %{$object} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 10 | local $_ = $object->{$index}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 10 | my $ret = $cpt->reval($code); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 10 | ▶ | croak qq{Error in filter: $@} if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 10 | ▶ | push @matching, $index if $ret; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 5 | for my $index ( 0 .. $#{$object} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 18 | local $_ = $object->[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 18 | my $ret = $cpt->reval($code); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 18 | ▶ | croak qq{Error in filter: $@} if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 18 | ▶ | push @matching, $index if $ret; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 7 | return @matching; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 266 | ▶ | sub _compare { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compare: called CC=21 SCAR=32.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 266 | my ( $operator, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 20 | ▶ | no warnings qw/uninitialized/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 266 | ▶ | if ( $operator eq $OPERATOR_IS_TRUE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 15 | ▶ | return $lhs ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 251 | ▶ | my $use_numeric = looks_like_number($lhs) && looks_like_number($rhs); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
&looks_like_number($lhs) && &looks_like_number($rhs)
MC/DC100%2/2
&looks_like_number($lhs) && &looks_like_number($rhs)
&looks_like_number($lhs)
&looks_like_number($rhs)
Truth table100%3/3
A && B
A= &looks_like_number($lhs)B= &looks_like_number($rhs)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 251 | ▶ | if ( $operator eq '=' || $operator eq '==' || $operator eq '===' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$operator eq "=" or $operator eq "==" or $operator eq "==="
$operator eq "=" or $operator eq "=="
MC/DC66%2/3
$operator eq "=" or $operator eq "==" or $operator eq "==="
$operator eq "="
$operator eq "=="
$operator eq "==="
Truth table75%3/4
A or B or C
A= $operator eq "="B= $operator eq "=="C= $operator eq "==="
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 66 | ▶ | return $use_numeric ? ( $lhs == $rhs ) : $lhs eq $rhs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 185 | ▶ | if ( $operator eq '<' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 26 | ▶ | return $use_numeric ? ( $lhs < $rhs ) : $lhs lt $rhs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 159 | ▶ | if ( $operator eq '>' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 83 | ▶ | return $use_numeric ? ( $lhs > $rhs ) : $lhs gt $rhs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 76 | ▶ | if ( $operator eq '<=' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | return $use_numeric ? ( $lhs <= $rhs ) : $lhs le $rhs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 76 | ▶ | if ( $operator eq '>=' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 22 | ▶ | return $use_numeric ? ( $lhs >= $rhs ) : $lhs ge $rhs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 54 | ▶ | if ( $operator eq '!=' || $operator eq '!==' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$operator eq "!=" or $operator eq "!=="
MC/DC0%0/2
$operator eq "!=" or $operator eq "!=="
$operator eq "!="
$operator eq "!=="
Truth table33%1/3
A or B
A= $operator eq "!="B= $operator eq "!=="
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | return $use_numeric ? ( $lhs != $rhs ) : $lhs ne $rhs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 54 | ▶ | if ( $operator eq '=~' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 54 | ▶ | if ( $rhs =~ m@^/(.*)/([msian]*)$@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 54 | my $regex = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 54 | my $modifiers = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 54 | return $lhs =~ qr/(?$modifiers)$regex/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | warn("Regexp need to be sorrounded by //. Allowed modifiers: msian"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 20 | ▶ | use warnings qw/uninitialized/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 20 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||