YAML



examples/references/yaml.yml
---
people:
  Bar:
    phones:
      - 345
      - 678
    title: CEO
  Baz: NA
  Foo:
    phone: 123

examples/references/yaml_dump.pl
#!/usr/bin/perl
use strict;
use warnings;

use YAML qw(DumpFile);

my $data_structure = {
    people => {
        Foo     => {
                phone => '123',
        },
        Bar     => {
            phones => [
                    '345',
                    '678',
            ],
            title => 'CEO',
        },
        Baz     => 'NA',
    }
};

DumpFile 'data.yml', $data_structure;

examples/references/yaml_load.pl
#!/usr/bin/perl
use strict;
use warnings;

use YAML qw(LoadFile);
my $data = LoadFile('data.yml');
print "$data->{people}->{Foo}->{phone}\n";          # 123
print "$data->{people}->{Bar}->{phones}->[0]\n";    # 345
print "$data->{people}->{Baz}\n";                   # NA