JCONF::Writer - Create JCONF configuration from perl code
use strict; use JCONF::Writer; use JCONF::Writer::Boolean qw(TRUE FALSE); my $writer = JCONF::Writer->new(autodie => 1); my %cfg = ( modules => { Moose => 1, Mouse => 0.91, Moo => 0.05, Mo => [0.01, 0.08], }, enabled => TRUE, data => ["Test data", "Production data"] query => q!SELECT * from pkg LEFT JOIN ver ON pkg.id=ver.pkg_id WHERE pkg.name IN ("Moose", "Mouse", "Moo", "Mo")! ); my $jconf = eval { $writer->from_hashref(\%cfg); }; if ($@) { die "Invalid config: ", $@; } print $jconf; __END__ modules = { Moose: 1, Mouse: 0.91, Moo: 0.05, Mo: [0.01, 0.08], } enabled = true data = ["Test data", "Production data"] query = "SELECT * from pkg LEFT JOIN ver ON pkg.id=ver.pkg_id WHERE pkg.name IN (\"Moose\", \"Mouse\", \"Moo\", \"Mo\")"
This is writer object constructor. Available parameters are:
throw exception on any error if true, default is false (in this case writer methods will return undef on error and error may be found with "last_error" method)
Converts hash reference to valid formatted JCONF and returns it as string. On fail returns undef/throws exception (according to autodie option in the constructor).
autodie
Returns error occured for last writer call. Error will be JCONF::Writer::Error object or undef (if there was no error).
JCONF::Writer::Error
Parse::JCONF
Copyright Oleg G <oleg@cpan.org>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install JCONF::Writer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JCONF::Writer
CPAN shell
perl -MCPAN -e shell install JCONF::Writer
For more information on module installation, please visit the detailed CPAN module installation guide.