pileofrogs has asked for the wisdom of the Perl Monks concerning the following question:

What's the best way to serialize/de-serialize an object with YAML? Is it any different for inside-out objects vs. normal hash-based objects? I need to keep this taint safe (no eval()).

Replies are listed 'Best First'.
Re: YAML & Objects
by chromatic (Archbishop) on Mar 17, 2006 at 21:30 UTC

    I use Class::StorageFactory. For inside-out objects, you need a method to call that returns serializable data.

Re: YAML & Objects
by gaal (Parson) on Mar 18, 2006 at 12:29 UTC
    In pugs, there already is a .yaml builtin that does this stuff for you:

    class Foo; has $.x; say Foo.new(:x<42>).yaml # --- !pugs/object:Foo # x: 42

    To deserialize, use the eval $str :lang<yaml> builtin. (Despite its name this does not run arbitrary code.)