Or slightly shorter:
use strict; use warnings; package Example; sub new { my $self = {}; $self->{'data'} = pop; return bless($self); } package main; use YAML qw(DumpFile LoadFile); # it will use YAML::XS if it installed use Data::Dumper; my $eg = Example->new("Hello world!"); my $save = DumpFile('test.yml', $eg); my $rest = LoadFile('test.yml'); warn Dumper $rest;
In reply to Re^2: Dynamically create objects from YAML
by zwon
in thread Dynamically create objects from YAML
by ennuikiller
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |