1TOML::Parser(3pm)     User Contributed Perl Documentation    TOML::Parser(3pm)
2
3
4

NAME

6       TOML::Parser - simple toml parser
7

SYNOPSIS

9           use TOML::Parser;
10
11           my $parser = TOML::Parser->new;
12           my $data   = $parser->parse($toml);
13

DESCRIPTION

15       TOML::Parser is a simple toml parser.
16
17       This data structure complies with the tests provided at
18       <https://github.com/toml-lang/toml/tree/v0.4.0/tests>.
19
20       The v0.4.0 specification is supported.
21

METHODS

23       my $parser = TOML::Parser->new(\%args)
24           Creates a new TOML::Parser instance.
25
26               use TOML::Parser;
27
28               # create new parser
29               my $parser = TOML::Parser->new();
30
31           Arguments can be:
32
33           ·   "inflate_datetime"
34
35               If use it, You can replace inflate "datetime" process.  The
36               subroutine of default is "identity". "e.g.) sub { $_[0] }"
37
38                   use TOML::Parser;
39                   use DateTime;
40                   use DateTime::Format::ISO8601;
41
42                   # create new parser
43                   my $parser = TOML::Parser->new(
44                       inflate_datetime => sub {
45                           my $dt = shift;
46                           return DateTime::Format::ISO8601->parse_datetime($dt);
47                       },
48                   );
49
50           ·   "inflate_boolean"
51
52               If use it, You can replace inflate boolean process.  The return
53               value of default subroutine is "Types::Serialiser::true" or
54               "Types::Serialiser::false".
55
56                   use TOML::Parser;
57
58                   # create new parser
59                   my $parser = TOML::Parser->new(
60                       inflate_boolean => sub {
61                           my $boolean = shift;
62                           return $boolean eq 'true' ? 1 : 0;
63                       },
64                   );
65
66           ·   "strict_mode"
67
68               TOML::Parser is using a more flexible rule for compatibility
69               with old TOML of default.  If make this option true value, You
70               can parse a toml with strict rule.
71
72                   use TOML::Parser;
73
74                   # create new parser
75                   my $parser = TOML::Parser->new(
76                       strict_mode => 1
77                   );
78
79       my $data = $parser->parse_file($path)
80       my $data = $parser->parse_fh($fh)
81       my $data = $parser->parse($src)
82           Transforms a string containing toml to a perl data structure or
83           vice versa.
84

SEE ALSO

86       TOML
87

LICENSE

89       Copyright (C) karupanerura.
90
91       This library is free software; you can redistribute it and/or modify it
92       under the same terms as Perl itself.
93

AUTHOR

95       karupanerura <karupa@cpan.org>
96

CONTRIBUTOR

98       Olivier Mengue <dolmen@cpan.org> yowcow <yowcow@cpan.org> Syohei
99       YOSHIDA <syohex@gmail.com>
100
101
102
103perl v5.30.0                      2019-10-01                 TOML::Parser(3pm)
Impressum