NAME
TOML - Parser for Tom's Obvious, Minimal Language.
SYNOPSIS
use TOML qw(from_toml to_toml);
# Parsing toml
my $toml = slurp("~/.foo.toml");
my $data = from_toml($toml);
# With error checking
my ($data, $err) = from_toml($toml);
unless ($data) {
die "Error parsing toml: $err";
}
# Creating toml
my $toml = to_toml($data);
DESCRIPTION
TOML implements a parser for Tom's Obvious, Minimal Language, as
defined at https://github.com/mojombo/toml. TOML exports two
subroutines, from_toml and to_toml,
FAQ
-
How change how to de-serialize?
You can change
$TOML::PARSERfor change how to de-serialize.example:
use TOML; use TOML::Parser; local $TOML::PARSER = TOML::Parser->new( inflate_boolean => sub { $_[0] eq 'true' ? \1 : \0 }, ); my $data = TOML::from_toml('foo = true');
FUNCTIONS
-
from_toml
from_tomltransforms a string containing toml to a perl data structure or vice versa. This data structure complies with the tests provided at https://github.com/mojombo/toml/tree/master/tests.If called in list context,
from_tomlproduces a (hash,error_string) tuple, whereerror_stringisundefon non-errors. If there is an error, thenhashwill be undefined anderror_stringwill contains (scant) details about said error. -
to_toml
to_tomltransforms a perl data structure into toml-formatted string.
SEE ALSO
AUTHOR
Darren Chamberlain darren@cpan.org
CONTRIBUTORS
- Tokuhiro Matsuno tokuhirom@cpan.org
- Matthias Bethke matthias@towiski.de
- Sergey Romanov complefor@rambler.ru
- karupanerura karupa@cpan.org
