Config::Utils - Common config utilities.
use Config::Utils qw(conflict hash hash_array); conflict($self, $config_hr, $key); hash($self, $key_ar, $val); hash_array($self, $key_ar, $val);
conflict
conflict($self, $config_hr, $key);
Check conflicts. Affected variables from $self:
$self
- set_conflicts - Flag, then control conflicts. - stack - Reference to array with actual 'C<$key>' key position.
Returns undef or fatal error.
hash
hash($self, $key_ar, $val);
Create record to hash. Affected variables from $self:
- config - Actual configuration in hash reference. - set_conflicts - Flag, then control conflicts. - stack - Reference to array with actual 'C<$key>' key position.
hash_array
hash_array($self, $key_ar, $val);
Create record to hash.
If exists more value record for one key, then create array of values.
Affected variables from $self:
conflict(): Conflict in '%s'. hash(): Conflict in '%s'. hash_array(): Conflict in '%s'.
use strict; use warnings; use Config::Utils qw(conflict); # Object. my $self = { 'set_conflicts' => 1, 'stack' => [], }; # Conflict. conflict($self, {'key' => 'value'}, 'key'); # Output: # ERROR: Conflict in 'key'.
use strict; use warnings; use Config::Utils qw(hash); use Dumpvalue; # Object. my $self = { 'config' => {}, 'set_conflicts' => 1, 'stack' => [], }; # Add records. hash($self, ['foo', 'baz1'], 'bar'); hash($self, ['foo', 'baz2'], 'bar'); # Dump. my $dump = Dumpvalue->new; $dump->dumpValues($self); # Output: # 0 HASH(0x955f3c8) # 'config' => HASH(0x955f418) # 'foo' => HASH(0x955f308) # 'baz1' => 'bar' # 'baz2' => 'bar' # 'set_conflicts' => 1 # 'stack' => ARRAY(0x955cc38) # empty array
use strict; use warnings; use Config::Utils qw(hash_array); use Dumpvalue; # Object. my $self = { 'config' => {}, 'set_conflicts' => 1, 'stack' => [], }; # Add records. hash_array($self, ['foo', 'baz'], 'bar'); hash_array($self, ['foo', 'baz'], 'bar'); # Dump. my $dump = Dumpvalue->new; $dump->dumpValues($self); # Output: # 0 HASH(0x8edf890) # 'config' => HASH(0x8edf850) # 'foo' => HASH(0x8edf840) # 'baz' => ARRAY(0x8edf6d0) # 0 'bar' # 1 'bar' # 'set_conflicts' => 1 # 'stack' => ARRAY(0x8edf6e0) # empty array
use strict; use warnings; use Config::Utils qw(hash_array); use Dumpvalue; # Object. my $self = { 'callback' => sub { my ($key_ar, $value) = @_; return uc($value); }, 'config' => {}, 'set_conflicts' => 1, 'stack' => [], }; # Add records. hash_array($self, ['foo', 'baz'], 'bar'); hash_array($self, ['foo', 'baz'], 'bar'); # Dump. my $dump = Dumpvalue->new; $dump->dumpValues($self); # Output: # 0 HASH(0x8edf890) # 'callback' => CODE(0x8405c40) # -> &CODE(0x8405c40) in ??? # 'config' => HASH(0x8edf850) # 'foo' => HASH(0x8edf840) # 'baz' => ARRAY(0x8edf6d0) # 0 'BAR' # 1 'BAR' # 'set_conflicts' => 1 # 'stack' => ARRAY(0x8edf6e0) # empty array
Error::Pure, Exporter, Readonly.
Module for simple configure file parsing.
Module for simple configure file parsing with arrays.
https://github.com/michal-josef-spacek/Config-Utils
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2011-2022 Michal Josef Špaček
BSD 2-Clause License
0.08
To install Config::Utils, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Utils
CPAN shell
perl -MCPAN -e shell install Config::Utils
For more information on module installation, please visit the detailed CPAN module installation guide.