-
-
17 Apr 2015 14:00:03 UTC
- Distribution: Data-YAML
- Module version: 0.0.7
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (2)
- Testers (2404 / 0 / 0)
- Kwalitee
Bus factor: 0- License: perl_5
- Activity
24 month- Tools
- Download (12.63KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Test::More
- version
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
Why not adopt me?
This distribution is up for adoption! If you're interested then please contact the PAUSE module admins via email.- NAME
- VERSION
- SYNOPSIS
- DESCRIPTION
- INTERFACE
- BUGS AND LIMITATIONS
- SEE ALSO
- AUTHOR
- LICENCE AND COPYRIGHT
- DISCLAIMER OF WARRANTY
NAME
Data::YAML::Writer - Easy YAML serialisation
VERSION
This document describes Data::YAML::Writer version 0.0.7
SYNOPSIS
use Data::YAML::Writer; my $data = { one => 1, two => 2, three => [ 1, 2, 3 ], }; my $yw = Data::YAML::Writer->new; # Write to an array... $yw->write( $data, \@some_array ); # ...an open file handle... $yw->write( $data, $some_file_handle ); # ...a string ... $yw->write( $data, \$some_string ); # ...or a closure $yw->write( $data, sub { my $line = shift; print "$line\n"; } );
DESCRIPTION
Encodes a scalar, hash reference or array reference as YAML.
In the spirit of YAML::Tiny this is a lightweight, dependency-free YAML writer. While
YAML::Tiny
is designed principally for working with configuration filesData::YAML
concentrates on the transparent round-tripping of YAML serialized Perl data structures.The syntax produced by
Data::YAML::Writer
is a subset of YAML. Specifically it is the same subset of YAML that Data::YAML::Reader consumes. See Data::YAML for more information.INTERFACE
new
-
The constructor
new
creates and returns an emptyData::YAML::Writer
object. write( $obj, $output )
-
Encode a scalar, hash reference or array reference as YAML.
my $writer = sub { my $line = shift; print SOMEFILE "$line\n"; }; my $data = { one => 1, two => 2, three => [ 1, 2, 3 ], }; my $yw = Data::YAML::Writer->new; $yw->write( $data, $writer );
The
$output
argument may bea reference to a scalar to append YAML to
the handle of an open file
a reference to an array into which YAML will be pushed
a code reference
If you supply a code reference the subroutine will be called once for each line of output with the line as its only argument. Passed lines will have no trailing newline.
BUGS AND LIMITATIONS
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.SEE ALSO
YAML::Tiny, YAML, YAML::Syck, Config::Tiny, CSS::Tiny
AUTHOR
Andy Armstrong
<andy@hexten.net>
LICENCE AND COPYRIGHT
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.
DISCLAIMER OF WARRANTY
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.
Module Install Instructions
To install Data::YAML, copy and paste the appropriate command in to your terminal.
cpanm Data::YAML
perl -MCPAN -e shell install Data::YAML
For more information on module installation, please visit the detailed CPAN module installation guide.