Adam Kennedy


YAML::Tiny::Stream - Document psuedo-streaming for YAML::Tiny


  my $parser = YAML::Tiny::Stream->new('lots-of-documents.yml');
  while ( my $yaml = $parser->fetch ) {
      # Handle the document


To keep the design small and contained, YAML::Tiny intentionally discards support for streamed parsing of YAML documents.

In situations where a file contains a very large number of very small YAML documents, YAML::Tiny::Stream provides a limited implementation of streaming that scans for YAML's --- document separators and parses them one entire document at a time.

Please note this approach does come with caveats, as any situation in which a triple dash occurs legitimately at the beginning of a line (such as in a quote) may be accidently detected as a new document by mistake.

If you really do need a "proper" streaming parser, then you should see YAML or one of the other full blown YAML implementations.



  my $stream = YAML::Tiny::Stream->new($file);

The new constructor creates a new stream handle.

It takes a single parameter of a file name, which it will open via IO::File.

In this quick initial implementation, the file handle will remain open until the stream object is destroyed.


The file accessor returns the original file passed to the constructor.


The handle accessor returns the IO handle being used to read in the YAML stream.


  my $yaml_tiny = $stream->fetch;

The fetch method reads from the file until it hits the end of the next document. This document is then passed to YAML::Tiny to be parsed.

Returns a YAML::Tiny object containing a single document, or undef if there are no more documents in the stream. Throws an exception if there is an IO or parsing error.


Bugs should be reported via the CPAN bug tracker at

For other issues, contact the author.


Adam Kennedy <>


YAML, YAML::Syck, Config::Tiny, CSS::Tiny,,


Copyright 2011 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.