Re: raku-toml confusion

[email protected] (Peter Pentchev) Sat, 24 May 2025 12:40:35 +0300
Newsgroups perl.perl6.users
Message-ID <[email protected]>
On Fri, May 23, 2025 at 05:44:01PM -0700, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
> https://github.com/tony-o/raku-toml
> 
> In the usage parsing example:
> 
>     Parsing TOML
>     use TOML;
>     my $config = from-toml("config.toml".IO.slurp);
>     # use $config like any ol' hash
> 
> This makes perfect sense to me.

...then you realize that the from-toml() function accepts a string,
not a file, right? The string that was read from the "config.toml"
file by the .IO.slurp() method.

> But in the Generating TOML example:
> 
>    use TOML;
>    my $config = {
>      bands => ['green day',
>                'motorhead',
>                't swift',],
>      favorite => 'little big',
>    };
>    my $toml-config = to-toml($config);
> 
> I am confused.  Seems to me he left something out.
> If this creates a TOML file for you, what/where
> is the file name and path?  What am I missing?

...and to-toml() also produces a string. If you want to write it to
a file, you need to do that yourself later.

Hope that helps!

G'luck,
Peter

-- 
Peter Pentchev  [email protected] [email protected] [email protected]
PGP key:        https://www.ringlet.net/roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEELuenpRf8EkzxFcNUZR7vsCUn3xMFAmgxlA4ACgkQZR7vsCUn
3xOCdhAAhWQkDnVXJG/Jh6ha1lPiN/e30R3bHbyl2+VRF1x878THd1duAB4sV5l+
X8bOIzh7WJhaUQgQ4W3bXmw0W5yDR1z8Xc2pCL53Gedz3lJ8uXNz1KkQehGVnH4M
hHFzmI2oB70AF0vVEw5NHT/Uu0aFDvTRGxafxNaXQY1QWGLPkb3XpkUwWnXNAJUs
3vnNKXSEacdb6k28iT7pGF5yFZ0tmSSEK5gnp7U1bEv+YUORRBI/R5OC0yjhXzEm
HmqPhDJ9IQz74+gG3vKKFiD0SQlP/UOI9+auto7TfsHvu0LczyBum9+Y+7EhA53K
GHz2mTffiTiyIN0pKCgLFBaMqcZhGw8hBaayWO3rIXrTZiC6lsMY020Ein9Le+uM
BwulqhO6fPUTHNHB7OV/cYGLlm7RsSztcuZMLZqr9dotmkqXdcmk8kGcK/BbsJAM
DICmFKJjYIKDGSzbkfJVYiQNWqMHIpygH2XE3r+giZ9yLu8KfpJh8FHKE5vIMpNO
8QY4qZmWLZ4IsdXezod/PjgBWp7PMQK+jeut1SF7gaZrmi6vPJo1K6s1G8nUyJ4k
YCddYe8wrurESKBBplXJ0uWbHVdwcbGZR4lDPnlGtY00jV4R7oDpG1g21TEUcAOS
EdqB3vF2rpc81dzPJDrAWU8xml0FSdEIYGqjb3C+TeFLH1TIm+c=
=WdyN
-----END PGP SIGNATURE-----