use PPR; use Modern::Perl; use Data::Dumper; use Config::General; use Sub::Signatures; my $conf = Config::General->new( -ConfigFile => "pm5.ini", -Plug => { post_parse_value => sub ($name, $value) { $value = split_array_str( $value ) if looks_like_array( $value ) ; return 1, $name, $value; } } ); #naive implementation, excercise for the reader to improve #PPR might be useful to parse this, assuming Perl syntax for the #array sub split_array_str ($value) { return [split ",", substr($value, 1, -1)]; } #naive implementation, excercise for the reader to improve sub looks_like_array ($value) { return $value =~ m#^\[# && $value =~ m#\]$#; } my %conf = $conf->getall; print Dumper( \%conf );
In reply to Re: Config::General to read both scalars and arrays
by holli
in thread Config::General to read both scalars and arrays
by The_Marshall
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |