YAML::Any(3)
π YAML::Any β the manual, but make it a group chat π
User Contributed Perl Documentation Β· YAML::Any(3) Β· bestie edition π
β¨ NAME β¨
YAML::Any β pick a YAML implementation and just, like, use it. π
π¨ STATUS π¨
WARNING: this module is about to be deprecated. Not me breaking the news π The plan is that YAML.pm itself will act like an Any module. So yeah. Heads up. π«Ά
π SYNOPSIS π
use YAML::Any;
$YAML::Indent = 3;
my $yaml = Dump(@objects);
That's the whole vibe. use it, set your indent, dump your stuff. Iconic. β¨
π DESCRIPTION π
So there's a whole little friend group of YAML implementations out there, and they all support the Dump/Load API. This module's whole job is picking the best one available and using that one. Like a friend who picks the restaurant. π
π ORDER π
Right now, YAML::Any picks the first one of these that's actually installed on your system:
YAML::XSYAML::SyckYAML::OldYAMLYAML::Tiny
First come, first served. No cap. π₯
π OPTIONS π
If you set an option like this:
$YAML::Indent = 4;
and YAML::Any happens to be running on YAML::XS, then it'll use the proper variable instead β that being $YAML::XS::Indent. It translates for you. It's giving translator bestie. π¦
π§ SUBROUTINES π§
Like every YAML module that YAML::Any uses, these subroutines are exported by default:
DumpLoad
and these ones are exportable by request (so you gotta ask nicely, i.e. in your use line):
DumpFileLoadFile
πΈ METHODS πΈ
YAML::Any provides the following class methods. π«Ά
YAML::Any->order
This method returns a list of all the current possible implementations that YAML::Any will search through. It's the shortlist. The roster. The lineup. β
YAML::Any->implementation
This method returns the implementation that YAML::Any will actually use.
How's it figure that out? It finds the first member of YAML::Any->order that is either already loaded in %INC or that can be loaded with require. If it can't find any implementation, it throws an error. π Periodt.
π EXAMPLES π
DumpFile and LoadFile
Here's an example for DumpFile:
#!/usr/bin/perl
use strict;
use warnings;
use YAML::Any qw(DumpFile);
my $ds =
{
array => [5,6,100],
string => "Hello",
};
DumpFile("hello.yml", $ds);
When you run it, it creates a file called hello.yml in the current working directory, with these contents inside:
---
array:
- 5
- 6
- 100
string: Hello
And then, in turn, this LoadFile example loads the contents from there and accesses them:
#!/usr/bin/perl
use strict;
use warnings;
use YAML::Any qw(LoadFile);
my ($ds) = LoadFile("hello.yml");
print "String == '", $ds->{string}, "'\n";
Assuming hello.yml exists, and is exactly what the DumpFile example made, it prints:
$ perl load.pl
String == 'Hello'
$
Look at that. Output. Slay. π
π AUTHOR π
Ingy dΓΆt Net <ingy@cpan.org>
π COPYRIGHT π
Copyright 2001-2014. Ingy dΓΆt Net
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>
And that's the whole page, bestie π«Ά this one came from perl v5.42.2 and it's dated 2026-07-27 β YAML::Any(3), go forth and dump responsibly π
β¨
π¦ where this page comes from
- fedora 43: perl-YAML 1.32.1-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-YAML 1.32.1-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms