TOML(3pm)

πŸ“¦
version 0.97 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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