in reply to Re: Dynamically create objects from YAML
in thread Dynamically create objects from YAML

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;