YAML::XS from CPAN (http://search.cpan.org/dist/YAML-LibYAML/lib/YAML/XS.pm). For example:
#!/usr/bin/perl -w use strict; package example; # object definition sub new { my $self = {}; $self->{'data'} = pop; return bless($self); } sub getData { my $self = shift; return $self->{'data'} } package Main; use YAML::XS; my $eg = new example("Hello world!\n"); my $save = Dump $eg; # object instance to yaml markup # save yaml markup to file open (EG, '>yaml.test') || die; print EG $save; close(EG); $save = $eg = undef; # clear variables # now load yaml markup from file open (EG, '<yaml.test') || die; $save .= $_ while (<EG>); close(EG); # yaml markup back into object $eg = Load $save; print $eg->getData(); # proof!
Dump and Load are the YAML::XS commands.
In reply to Re: Dynamically create objects from YAML
by halfcountplus
in thread Dynamically create objects from YAML
by ennuikiller
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |