7 $YAML::Any::VERSION = '0.70';
8 @YAML::Any::ISA = 'Exporter';
9 @YAML::Any::EXPORT = qw(Dump Load);
10 @YAML::Any::EXPORT_OK = qw(DumpFile LoadFile);
12 my @dump_options = qw(
30 my @load_options = qw(
35 my @implementations = qw(
44 __PACKAGE__->implementation;
45 goto &Exporter::import;
50 my $implementation = __PACKAGE__->implementation;
51 for my $option (@dump_options) {
52 my $var = "$implementation\::$option";
55 $$var = defined $value ? $value : ${"YAML::$option"};
57 return &{"$implementation\::Dump"}(@_);
62 my $implementation = __PACKAGE__->implementation;
63 for my $option (@dump_options) {
64 my $var = "$implementation\::$option";
67 $$var = defined $value ? $value : ${"YAML::$option"};
69 return &{"$implementation\::DumpFile"}(@_);
74 my $implementation = __PACKAGE__->implementation;
75 for my $option (@load_options) {
76 my $var = "$implementation\::$option";
79 $$var = defined $value ? $value : ${"YAML::$option"};
81 return &{"$implementation\::Load"}(@_);
86 my $implementation = __PACKAGE__->implementation;
87 for my $option (@load_options) {
88 my $var = "$implementation\::$option";
91 $$var = defined $value ? $value : ${"YAML::$option"};
93 return &{"$implementation\::LoadFile"}(@_);
97 return @YAML::Any::_TEST_ORDER
98 if defined @YAML::Any::_TEST_ORDER;
99 return @implementations;
103 my @order = __PACKAGE__->order;
104 for my $module (@order) {
108 return $module if exists $INC{$path};
109 eval "require $module; 1" and return $module;
111 croak("YAML::Any couldn't find any of these YAML implementations: @order");
123 YAML::Any - Pick a YAML implementation and use it.
129 my $yaml = Dump(@objects);
133 There are several YAML implementations that support the Dump/Load API.
134 This module selects the best one available and uses it.
138 Currently, YAML::Any will choose the first one of these YAML
139 implementations that is installed on your system:
149 If you specify an option like:
153 And YAML::Any is using YAML::XS, it will use the proper variable:
158 Like all the YAML modules that YAML::Any uses, the following subroutines
159 are exported by default:
164 and the following subroutines are exportable by request:
171 YAML::Any provides the following class methods.
175 =item YAML::Any->order;
177 This method returns a list of the current possible implementations that
178 YAML::Any will search for.
180 =item YAML::Any->implementation;
182 This method returns the implementation the YAML::Any will use. This
183 result is obtained by finding the first member of YAML::Any->order that
184 is either already loaded in C<%INC> or that can be loaded using
185 C<require>. If no implementation is found, an error will be thrown.
191 Ingy döt Net <ingy@cpan.org>
195 Copyright (c) 2008. Ingy döt Net.
197 This program is free software; you can redistribute it and/or modify it
198 under the same terms as Perl itself.
200 See L<http://www.perl.com/perl/misc/Artistic.html>