Config-General-Hierarchical
view release on metacpan or search on metacpan
Hierarchical/Dump.pm view on Meta::CPAN
$
$ cat example.conf
#!/usr/local/bin/perl -MConfig::General::Hierarchical::Dump
variable1 value
variable2
<node>
key value
</node>
$
$ chmod 755 example.conf
$ ./example.conf
node->key = 'value'
variable1 = 'value'
variable2 = ''
$
$
Full use:
package MyConfig::Dump;
t/99_dump.t view on Meta::CPAN
$tests = 59;
}
use Test::More tests => $tests;
use Test::Differences;
require_ok Config::General::Hierarchical::Dump;
require_ok Config::General::Hierarchical::DumpTest;
`echo "#!$^X -MConfig::General::Hierarchical::Dump\nvariable value\n<node>\n key value\n keys\n</node>\ndefined" > t/dump.conf`;
`chmod 755 t/dump.conf`;
is( `t/dump.conf`, <<EOF, 'self execution' );
defined = '';
node->key = 'value';
node->keys = '';
variable = 'value';
EOF
my $cfg = Config::General::Hierarchical->new( file => 't/dump.conf' );
my $res = '';
t/99_dump.t view on Meta::CPAN
-c, --check if present, prints only the variables that do
not respect syntax constraint
-f, --file shows in which file variables are defined
-l, --fixed-length formats output as fixed length fields
-h, --help prints this help and exits
-j, --json prints output as json
EOF
`mkdir -p t/dir`;
`echo "#!$^X -MConfig::General::Hierarchical::DumpTest\ninherits ../dump_inherited.conf\nvalue value\n<node>\n undefined key\n undefined value\n</node>\narray 1\narray 2" > t/dir/dump_inherits.conf`;
`chmod 755 t/dir/dump_inherits.conf`;
is( `t/dir/dump_inherits.conf`, <<EOF, 'inherited self execution' );
array = ( '1', '2' );
defined = 'really defined';
node->array = ( 's1', 's2' );
node->key = undef;
node->value = error;
value = error;
EOF
t/99_dump.t view on Meta::CPAN
'',
Config::General::Hierarchical::DumpTest->do_all(
't/dump_substitutions2.conf', ['-l']
)
),
"node->array = *;\n* = ( 'a\nb', 'a\nb\n' );\nnode->key = 'ab';\n",
'subs 2'
);
`echo "#!$^X -MConfig::General::Hierarchical::Dump=Config::General::Hierarchical::Test\nvariable value\n<node>\n key value\n keys\n</node>\ndefined\nvalue a" > t/import.conf`;
`chmod 755 t/import.conf`;
is( `t/import.conf`, <<EOF, 'import param 1' );
defined = '';
node->key = 'value';
node->keys = '';
value = error;
variable = 'value';
EOF
is(
( run in 0.244 second using v1.01-cache-2.11-cpan-8d75d55dd25 )