X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=lib%2FConfig%2FAny%2FYAML.pm;h=1f612211da5ebe806012efa3feed1ea61544eab2;hp=c2f852df98029e43301097bed6e8d07fc1907ce2;hb=19f6cb6387c498de75ffc388b5db53c9da678e05;hpb=d49610ab8c8f7a8fa979a60fa75eb20ae690135b diff --git a/lib/Config/Any/YAML.pm b/lib/Config/Any/YAML.pm index c2f852d..1f61221 100644 --- a/lib/Config/Any/YAML.pm +++ b/lib/Config/Any/YAML.pm @@ -5,6 +5,8 @@ use warnings; use base 'Config::Any::Base'; +use Carp (); + =head1 NAME Config::Any::YAML - Load YAML config files @@ -19,7 +21,6 @@ Loads YAML files. Example: foo: bar Model::Baz: qux: xyzzy - =head1 METHODS @@ -43,8 +44,10 @@ sub load { my $class = shift; my $file = shift; - eval { require YAML::Syck; YAML::Syck->VERSION( '0.70' ) }; - unless ( $@ ) { + if (eval { require YAML::XS; 1 }) { + return YAML::XS::LoadFile( $file ); + } + elsif ($] > 5.008008 && eval { require YAML::Syck; YAML::Syck->VERSION(0.70) } ) { open( my $fh, $file ) or die $!; my $content = do { local $/; <$fh> }; close $fh; @@ -57,12 +60,14 @@ sub load { =head2 requires_any_of( ) -Specifies that this modules requires one of L (0.70) or L in -order to work. +Specifies that this modules requires one of L, L (0.70) or +L in order to work. =cut -sub requires_any_of { [ 'YAML::Syck', '0.70' ], 'YAML' } +sub requires_any_of { + 'YAML::XS', ( $] > 5.008008 ? [ 'YAML::Syck', '0.70' ] : ()), 'YAML'; +} =head1 AUTHOR @@ -70,19 +75,21 @@ Brian Cassidy Ebricas@cpan.orgE =head1 COPYRIGHT AND LICENSE -Copyright 2007 by Brian Cassidy +Copyright 2006-2016 by Brian Cassidy This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. =head1 SEE ALSO -=over 4 +=over 4 =item * L =item * L +=item * L + =item * L =item * L