YAML-Perl/lib/YAML/Perl.pod
=encoding utf8
=head1 NAME
YAML::Perl - Pure Perl YAML Implementation
=head1 WARNING
This is an early release of PyYaml ported to Perl. Don't even bother to
try this version.
Still here?
This port is nearing completion. Most stuff works including:
* Loading and dumping of basic types
* Block and flow styles (JSON Loading)
* Blessed hashes arrays and scalars
* References
* Tags
* Detailed error messages
* Lot's of new stuff like parser/emitter streaming api
You can play with it by using:
ysh -MYAML::Perl
=head1 TODO
* Review all code ported so far
* Port diff from old copy of pyyaml to current version
* Do all the utf8 related code porting that I've ignored
* Port the pyyaml test suite to Perl
* Get all tests to pass
* Support esoteric Perl types like regexps and globs
* Support the PyYAML tag resolution API
* Write full documentation for YAML::Perl
* Support YAML::Node from YAML::Perl
=head1 SYNOPSIS
use YAML::Perl;
my $data = {
name => 'Ingy döt Net',
modules => [
'YAML', 'YAML::Old', 'YAML::Perl', YAML::XS'
],
};
my $yaml = <<'...';
---
modules:
- YAML
- YAML::Old
- YAML::Perl
- YAML::XS
name: Ingy döt Net
...
# Simple, familiar, Dump/Load API
my $yaml2 = Dump $data;
my $data2 = Load $yaml;
# New, non-global dump API:
my $yaml3 = YAML::Perl->new->dumper(%options)->dump($data);
# New load API
my $data3 = YAML::Perl->new->loader(%options)->open($yaml)->load();
# New Streaming Parser/Emitter API
my $yaml4;
my $parser = YAML::Perl->new->parser->open($yaml);
my $emitter = YAML::Perl->new-emitter->open($yaml4);
while (my $event = $parser->parse()) {
# Do various things with events here
$emitter->emit($event);
}
$emitter->close;
print $yaml4;
=head1 DESCRIPTION
PyYAML is the most robust and correct YAML module for a dynamic
language. It is (obviously) written in/for Python. This module is a
complete port of PyYAML to Perl.
=head1 STREAMING API
YAML::Parser reads a YAML serialization stream and produces
events. YAML::Emitter takes YAML events and produces a YAML
serialization stream.
Both of these modules allow you to process all the yaml/events at once,
or do things one event at a time. If you call the YAML::Parser
C<parse()> method in list context, you get all the remaining event
objects. If you call it in scalar context, you get the next event.
The YAML::Emitter C<emit()> method takes one or more event objects as
input arguments.
=head1 AUTHOR
Ingy döt Net <ingy@cpan.org>
=head1 COPYRIGHT
Copyright (c) 2008, 2009. 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
=cut