TOML::Parser(3pm)

πŸ“¦
version 0.91 Β· 6 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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