Sponsoring The Perl Toolchain Summit 2025: Help make this important event another success Learn more

NAME

Catmandu::Importer::YAML - Package that imports YAML data

SYNOPSIS

# From the command line
$ catmandu convert YAML to JSON < data.yaml
# In a Perl script
my $importer = Catmandu->importer('YAML',file => "/foo/bar.yaml");
my $n = $importer->each(sub {
my $hashref = $_[0];
# ...
});
The YAML input file needs to be separated into records:
---
- recordno: 1
- name: Alpha
---
- recordno: 2
- name: Beta
...
where '---' is the record separator and '...' the EOF indicator.

CONFIGURATION

file

Read input from a local file given by its path. Alternatively a scalar reference can be passed to read from a string.

fh

Read input from an IO::Handle. If not specified, Catmandu::Util::io is used to create the input stream from the file argument or by using STDIN.

encoding

Binmode of the input stream fh. Set to :utf8 by default.

fix

An ARRAY of one or more fixes or file scripts to be applied to imported items.

METHODS

Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited. The Catmandu::Importer::YAML methods are not idempotent: YAML feeds can only be read once.

SEE ALSO

Catmandu::Exporter::YAML