| 1 | ## no critic (ControlStructures::ProhibitPostfixControls) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## no critic (ControlStructures::ProhibitCascadingIfElse) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## no critic (ValuesAndExpressions::ProhibitConstantPragma) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package Env::Assert::Functions; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # ABSTRACT: The functionality of Env::Assert and bin/envassert. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | our $VERSION = '0.015'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | assert | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | report_errors | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | file_to_desc | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ENV_ASSERT_MISSING_FROM_ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ENV_ASSERT_INVALID_CONTENT_IN_VARIABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ENV_ASSERT_MISSING_FROM_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 'all' => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | assert | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | report_errors | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | file_to_desc | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ENV_ASSERT_MISSING_FROM_ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ENV_ASSERT_INVALID_CONTENT_IN_VARIABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ENV_ASSERT_MISSING_FROM_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 'constants' => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ENV_ASSERT_MISSING_FROM_ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ENV_ASSERT_INVALID_CONTENT_IN_VARIABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ENV_ASSERT_MISSING_FROM_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | ▶ | use Cwd qw( abs_path ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | ▶ | use English qw( -no_match_vars ); # Avoids regex performance penalty in perl 5.18 and earlier | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 6 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | ENV_ASSERT_MISSING_FROM_ENVIRONMENT => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ENV_ASSERT_INVALID_CONTENT_IN_VARIABLE => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ENV_ASSERT_MISSING_FROM_DEFINITION => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | DEFAULT_PARAMETER_BREAK_AT_FIRST_ERROR => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | INDENT => q{ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 8 | ▶ | sub assert { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert: called CC=18 SCAR=29.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | my ( $env, $want, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | ▶ | $params = {} if !$params; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 8 | ▶ | croak 'Invalid options. Not a hash' if ( ref $env ne 'HASH' || ref $want ne 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $env ne "HASH" or ref $want ne "HASH"
MC/DC0%0/2
ref $env ne "HASH" or ref $want ne "HASH"
ref $env ne "HASH"
ref $want ne "HASH"
Truth table33%1/3
A or B
A= ref $env ne "HASH"B= ref $want ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # Set default options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | ▶ | $params->{'break_at_first_error'} //= DEFAULT_PARAMETER_BREAK_AT_FIRST_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params->{"break_at_first_error"} //= 0
MC/DC100%1/1
$params->{"break_at_first_error"} //= 0
$params->{"break_at_first_error"}
Truth table100%2/2
A
A= $params->{"break_at_first_error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | my $success = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 8 | my %errors; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 8 | my $vars = $want->{'variables'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 8 | my $opts = $want->{'options'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 8 | foreach my $var_name ( keys %{$vars} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 14 | my $var = $vars->{$var_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 14 | ▶ | my $required = $var->{'required'} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$var->{"required"} // 1
MC/DC100%1/1
$var->{"required"} // 1
$var->{"required"}
Truth table100%2/2
A
A= $var->{"required"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 14 | ▶ | my $regexp = $var->{'regexp'} // q{.*}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$var->{"regexp"} // ".*"
MC/DC0%0/1
$var->{"regexp"} // ".*"
$var->{"regexp"}
Truth table50%1/2
A
A= $var->{"regexp"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 14 | ▶ | if ( ( $opts->{'exact'} || $required ) && !defined $env->{$var_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$opts->{"exact"} || $required and not defined $env->{$var_name}
$opts->{"exact"} or $required
MC/DC33%1/3
$opts->{"exact"} || $required and not defined $env->{$var_name}
$opts->{"exact"}
$required
not defined $env->{$var_name}
Truth table80%4/5
A or B and not(C)
A= $opts->{"exact"}B= $requiredC= not defined $env->{$var_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | $success = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | $errors{'variables'}->{$var_name} = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | type => ENV_ASSERT_MISSING_FROM_ENVIRONMENT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | message => "Variable $var_name is missing from environment", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | ▶ | goto EXIT if ( $params->{'break_at_first_error'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | elsif ( $env->{$var_name} !~ m/$regexp/msx ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | $success = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | $errors{'variables'}->{$var_name} = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | type => ENV_ASSERT_INVALID_CONTENT_IN_VARIABLE, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | message => "Variable $var_name has invalid content", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | goto EXIT if ( $params->{'break_at_first_error'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | ▶ | if ( $opts->{'exact'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 4 | foreach my $var_name ( keys %{$env} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 6 | ▶ | if ( !exists $vars->{$var_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | $success = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | $errors{'variables'}->{$var_name} = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | type => ENV_ASSERT_MISSING_FROM_DEFINITION, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | message => "Variable $var_name is missing from description", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | ▶ | goto EXIT if ( $params->{'break_at_first_error'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | EXIT: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | return { success => $success, errors => \%errors, }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 3 | ▶ | sub report_errors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
report_errors: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | my ($errors) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | my $out = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 3 | $out .= sprintf "Environment Assert: ERRORS:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 3 | foreach my $error_area_name ( sort keys %{$errors} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | $out .= sprintf "%s%s:\n", INDENT, $error_area_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | foreach my $error_key ( sort keys %{ $errors->{$error_area_name} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | $out .= sprintf "%s%s: %s\n", INDENT . INDENT, $error_key, $errors->{$error_area_name}->{$error_key}->{'message'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | ▶ | sub file_to_desc { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_to_desc: called CC=7 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | my @rows = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | my %desc = ( 'options' => {}, 'variables' => {}, ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | foreach (@rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # This is envassert meta command | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ## no critic (RegularExpressions::ProhibitComplexRegexes) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 17 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ^ [[:space:]]{0,} [#]{2} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | [[:space:]]{1,} envassert [[:space:]]{1,} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | [(] opts: [[:space:]]{0,} (?<opts> .*) [)] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | [[:space:]]{0,} $ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | }msx | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $opts = _interpret_opts( $LAST_PAREN_MATCH{opts} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | foreach ( keys %{$opts} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $desc{'options'}->{$_} = $opts->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | elsif ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # This is comment row | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ^ [[:space:]]{0,} [#]{1} .* $ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | }msx | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | elsif ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # This is empty row | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ^ [[:space:]]{0,} $ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | }msx | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | elsif ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # This is env var description | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ^ (?<name> [^=]{1,}) = (?<value> .*) $ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | }msx | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 7 | $desc{'variables'}->{ $LAST_PAREN_MATCH{name} } = { regexp => $LAST_PAREN_MATCH{value} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | return \%desc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # Private subroutines | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 6 | ▶ | sub _interpret_opts { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_interpret_opts: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 6 | my ($opts_str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 6 | my @opts = split qr{ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | [[:space:]]{0,} [,] [[:space:]]{0,} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | }msx, $opts_str; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 6 | my %opts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 6 | foreach (@opts) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 11 | my ( $key, $val ) = split qr/=/msx; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 11 | $opts{$key} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 6 | return \%opts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||