Config-Dot
view release on metacpan or search on metacpan
return $self;
}
# Parse text or array of texts.
sub parse {
my ($self, $string_or_array_ref) = @_;
my @text;
if (ref $string_or_array_ref eq 'ARRAY') {
@text = @{$string_or_array_ref};
} else {
@text = split m/$INPUT_RECORD_SEPARATOR/sm,
$string_or_array_ref;
}
foreach my $line (@text) {
$self->{'count'}++;
$self->_parse($line);
}
return $self->{'config'};
}
# Reset content.
# Remove comments on single line.
$string =~ s/^\s*#.*$//sm;
# Blank space.
if ($string =~ m/^\s*$/sm) {
return 0;
}
# Split.
my ($key, $val) = split m/=/sm, $string, 2;
# Not a key.
if (length $key < 1) {
return 0;
}
# Bad key.
if ($key !~ m/^[-\w\.:,]+\+?$/sm) {
err "Bad key '$key' in string '$string' at line ".
"'$self->{'count'}'.";
}
my @tmp = split m/\./sm, $key;
hash($self, \@tmp, $val);
# Ok.
return 1;
}
# Serialize.
sub _serialize {
my ($self, $config_hr) = @_;
my @ret;
( run in 1.024 second using v1.01-cache-2.11-cpan-71847e10f99 )