Data::YAML::Reader - Parse YAML created by Data::YAML::Writer
This document describes Data::YAML::Reader version 0.0.6
use Data::YAML::Reader; my $yr = Data::YAML::Reader->new; # Read from an array... my $from_array = $yr->read( \@some_array ); # ...an open file handle... my $from_handle = $yr->read( $some_file ); # ...a string containing YAML... my $from_string = $yr->read( $some_string ); # ...or a closure my $from_code = $yr->read( sub { return get_next_line() } );
In the spirit of YAML::Tiny this is a lightweight, dependency-free YAML reader. While YAML::Tiny is designed principally for working with configuration files Data::YAML concentrates on the transparent round-tripping of YAML serialized Perl data structures.
YAML::Tiny
Data::YAML
The syntax accepted by Data::YAML::Reader is a subset of YAML. Specifically it is the same subset of YAML that Data::YAML::Writer produces. See Data::YAML for more information.
Data::YAML::Reader
new
Creates and returns an empty Data::YAML::Reader object. No options may be passed.
read( $source )
Read YAML and return the data structure it represents. The YAML data may be supplied by a
scalar string containing YAML source
the handle of an open file
a reference to an array of lines
a code reference
In the case of a code reference a subroutine (most likely a closure) that returns successive lines of YAML must be supplied. Lines should have no trailing newline. When the YAML is exhausted the subroutine must return undef.
Returns the data structure (specifically either a scalar, hash ref or array ref) that results from decoding the YAML.
get_raw
Return the raw YAML source from the most recent read.
read
No bugs have been reported.
Please report any bugs or feature requests to data-yaml@rt.cpan.org, or through the web interface at http://rt.cpan.org.
data-yaml@rt.cpan.org
YAML::Tiny, YAML, YAML::Syck, Config::Tiny, CSS::Tiny
Andy Armstrong <andy@hexten.net>
<andy@hexten.net>
Adam Kennedy wrote YAML::Tiny which provided the template and many of the YAML matching regular expressions for this module.
Copyright (c) 2007, Andy Armstrong <andy@hexten.net>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
To install Data::YAML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::YAML
CPAN shell
perl -MCPAN -e shell install Data::YAML
For more information on module installation, please visit the detailed CPAN module installation guide.