Config-IOD-Reader
view release on metacpan or search on metacpan
* Found a section line
Arguments passed: "event" (str, 'section'), "linum", "line",
"cur_section", "section" (str, section name).
* Found a key line
Arguments passed: "event" (str, 'section'), "linum", "line",
"cur_section", "key" (str, key name), "val" (any, value name,
already decoded if encoded), "raw_val" (str, raw value).
TODO: callback when there is merging.
HOMEPAGE
Please visit the project's homepage at
<https://metacpan.org/release/Config-IOD-Reader>.
SOURCE
Source repository is at
<https://github.com/perlancar/perl-Config-IOD-Reader>.
lib/Config/IOD/Base.pm view on Meta::CPAN
}
push @argv, $buf if defined $buf;
if ($escaped || $single_quoted || $double_quoted) {
return undef; ## no critic: Subroutines::ProhibitExplicitReturnUndef
}
\@argv;
}
# return ($err, $res, $decoded_val)
sub _parse_raw_value {
my ($self, $val, $needs_res) = @_;
if ($val =~ /\A!/ && $self->{enable_encoding}) {
$val =~ s/!(\w+)(\s+)// or return ("Invalid syntax in encoded value");
my ($enc, $ws1) = ($1, $2);
my $res; $res = [
"!$enc", # COL_V_ENCODING
lib/Config/IOD/Reader.pm view on Meta::CPAN
# key line
if ($line =~ /^\s*([^=]+?)\s*=(\s*)(.*)/) {
my $key = $1;
my $space = $2;
my $val = $3;
if ($self->{warn_perl} && !$space && $val =~ /\A>/) {
$self->_warn("Probably using Perl syntax instead of INI: $line");
}
# the common case is that value are not decoded or
# quoted/bracketed/braced, so we avoid calling _parse_raw_value here
# to avoid overhead
if ($val =~ /\A["!\\[\{~]/) {
$_raw_val = $val if $cb;
my ($err, $parse_res, $decoded_val) = $self->_parse_raw_value($val);
$self->_err("Invalid value: " . $err) if $err;
$val = $decoded_val;
} else {
$_raw_val = $val if $cb;
$val =~ s/\s*[#;].*//; # strip comment
}
if (exists $res->{$cur_section}{$key}) {
if (!$self->{allow_duplicate_key}) {
$self->_err("Duplicate key: $key (section $cur_section)");
} elsif ($self->{_arrayified}{$cur_section}{$key}++) {
push @{ $res->{$cur_section}{$key} }, $val;
lib/Config/IOD/Reader.pm view on Meta::CPAN
Arguments passed: C<event> (str, 'comment'), C<linum>, C<line>, C<cur_section>.
=item * Found a section line
Arguments passed: C<event> (str, 'section'), C<linum>, C<line>, C<cur_section>,
C<section> (str, section name).
=item * Found a key line
Arguments passed: C<event> (str, 'section'), C<linum>, C<line>, C<cur_section>,
C<key> (str, key name), C<val> (any, value name, already decoded if encoded),
C<raw_val> (str, raw value).
=back
TODO: callback when there is merging.
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/Config-IOD-Reader>.
( run in 0.287 second using v1.01-cache-2.11-cpan-26ccb49234f )