Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • The nesting of data structures in YAML blocks is indicated by indenting. So that:

    optional_features:
      - foo:
        description:        test
        requires_os:        Linux
        requires:
          Test::More:       0.47

    is just a tight version of

    optional_features:
      -
        foo:
        description:        test
        requires_os:        Linux

    • by izut (6269) on 2007.02.28 10:19 (#53420) Journal

      You were almost there :-)

      Actually, you don't need the '-':

      #!env perl

      use strict;
      use strict;
      use warnings;

      use Data::Dumper;
      use YAML qw(Load);

      my $s = Load(<<EOF);
      ---
      optional_features:
        foo:
          description:        test
          requires_os:        Linux
          requires:
            Test::More:       0.47
        bar:
          description:        test

      EOF

      print Dumper $s;
      The result is this:

      $VAR1 = {
                'optional_features' => {
                                         'bar' => {
                                                    'description' => 'test'
                                                  },
                                         'foo' => {
                                                    'requires_os' => 'Linux',
                                                    'requires' => {
                                                                    'Test::More' => '0.47'
                                                                  },
                                                    'description' => 'test'
                                                  }
                                       }
              };
      --
      Igor Sutton