TOML(3pm)
β¨ NAME β¨
TOML β a 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 πΈ
okay bestie so TOML implements a parser for Tom's Obvious, Minimal Language, as defined at <https://github.com/mojombo/toml>. that's the whole vibe. π
and TOML exports two subroutines, from_toml and to_toml. just those two. iconic. periodt. β¨
π¦ FAQ π¦
How change how to de-serialize? π€
so like, you can change $TOML::PARSER for change how to de-serialize. yes literally that. π
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_toml transforms a string containing toml to a perl data structure or vice versa. and ngl that data structure complies with the tests provided at <https://github.com/mojombo/toml/tree/master/tests>. π«Ά
if it's called in list context, from_toml produces a ("hash", "error_string") tuple, where "error_string" is undef on non-errors. but if there is an error π then "hash" will be undefined and "error_string" will contains (scant) details about said error. scant details bestie. that's what we get. π
to_toml
to_toml transforms a perl data structure into toml-formatted string. that's it, that's the function, she's a queen. π
π SEE ALSO π
TOML::Parser
π LICENSE π
okay so legally speaking: this program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2.
this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. π see the GNU General Public License for more details.
you should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
π 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>
and that's the whole page bestie!! π this one's running on perl v5.34.0, dated 2022-06-28, and it's part of the User Contributed Perl Documentation collection. go parse some toml, you absolute icon π β¨π¦
π¦ where this page comes from
- debian bookworm: libtoml-perl 0.97-2 Β· GPL-2.0-or-later
- debian trixie: libtoml-perl 0.97-2 Β· GPL-2.0-or-later
- ubuntu noble: libtoml-perl 0.97-2 Β· GPL-2.0-or-later
- ubuntu resolute: libtoml-perl 0.97-2 Β· GPL-2.0-or-later
- ubuntu stonking: libtoml-perl 0.97-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms