TOML::Parser(3pm)
π TOML::Parser π
okay bestie, meet TOML::Parser β a simple toml parser, living its best life in the User Contributed Perl Documentation section of your man pages. she's not complicated, she's not dramatic, she just parses toml and looks cute doing it. π
β¨ NAME β¨
TOML::Parser β simple toml parser π¦
πΈ SYNOPSIS πΈ
use TOML::Parser;
my $parser = TOML::Parser->new;
my $data = $parser->parse($toml);
look at her. three lines. iconic. no notes. π
π DESCRIPTION π
TOML::Parser is a simple toml parser. that's the whole vibe, fr fr.
This data structure complies with the tests provided at https://github.com/toml-lang/toml/tree/v0.4.0/tests. so like, she passes the vibe check, officially. β
The v0.4.0 specification is supported. periodt. π
π METHODS π
π«Ά my $parser = TOML::Parser->new(\%args)
Creates a new TOML::Parser instance. brand new parser, brand new her. β¨
use TOML::Parser;
# create new parser
my $parser = TOML::Parser->new();
Arguments can be:
"inflate_datetime"β If use it, You can replace inflate"datetime"process. The subroutine of default is"identity"."e.g.) sub { $_[0] }"
use TOML::Parser;
use DateTime;
use DateTime::Format::ISO8601;
# create new parser
my $parser = TOML::Parser->new(
inflate_datetime => sub {
my $dt = shift;
return DateTime::Format::ISO8601->parse_datetime($dt);
},
);
"inflate_boolean"β If use it, You can replace inflate boolean process. The return value of default subroutine is"Types::Serialiser::true"or"Types::Serialiser::false".
use TOML::Parser;
# create new parser
my $parser = TOML::Parser->new(
inflate_boolean => sub {
my $boolean = shift;
return $boolean eq 'true' ? 1 : 0;
},
);
"strict_mode"β TOML::Parser is using a more flexible rule for compatibility with old TOML of default. If make this option true value, You can parse a toml with strict rule.
ngl bestie, default is the chill lenient mode for old-TOML compatibility. flip this on and she gets strict. no more vibes, only rules. π€
use TOML::Parser;
# create new parser
my $parser = TOML::Parser->new(
strict_mode => 1
);
π my $data = $parser->parse_file($path)
π my $data = $parser->parse_fh($fh)
π my $data = $parser->parse($src)
Transforms a string containing toml to a perl data structure or vice versa. both directions, she's versatile like that π«
π¦ SEE ALSO π¦
TOML
π LICENSE π
Copyright (C) karupanerura.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π AUTHOR π
karupanerura karupa@cpan.org
π CONTRIBUTOR π
Olivier Mengue dolmen@cpan.org yowcow yowcow@cpan.org Syohei YOSHIDA syohex@gmail.com
and that's the whole page bestie, no cap. this lil doc was brought to you by perl v5.36.0 and dated 2023-07-01, and honestly? she ate. π β¨ mwah, go parse something cute. ππ¦π
π¦ where this page comes from
- debian trixie: libtoml-parser-perl 0.91-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtoml-parser-perl 0.91-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtoml-parser-perl 0.91-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtoml-parser-perl 0.91-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms