in reply to Human-readable serialization formats other than YAML?

Although it's a lot more verbose than YAML, XML is a lot more robust. Have you tried XML::Simple for dump and restore?
  • Comment on Re: Human-readable serialization formats other than YAML?

Replies are listed 'Best First'.
Re^2: Human-readable serialization formats other than YAML?
by jasonk (Parson) on Apr 23, 2008 at 17:37 UTC

    Unless there is an option I missed somewhere, XML::Simple can't roundtrip perl objects either...

    use Test::More tests => 1; use Test::Differences; use XML::Simple; my $in = bless( { foo => 'bar' }, 'Something' ); my $out = XMLin( XMLout( $in ) ); eq_or_diff( $in, $out ); __END__ 1..1 not ok 1 # Failed test at foo.pl line 8. # +----+------------------+----------------+ # | Elt|Got |Expected | # +----+------------------+----------------+ # * 0|bless( { |{ * # | 1| foo => 'bar' | foo => 'bar' | # * 2|}, 'Something' ) |} * # +----+------------------+----------------+ # Looks like you failed 1 test of 1.

    www.jasonkohles.com
    We're not surrounded, we're in a target-rich environment!
      Sorry, I missed that you wanted to handle blessed objects. I think you'd better stick with something that understands perl then, like Data::Dumper.
      (Got, Expected) => (Expected, Got)

      Please note that the key return order in a hash is not guaranteed by perl. While it will be constant for a given version of perl on one OS it may well change with a different version of perl or even the same version on a different OS. This has bitten me before when writing tests for CPAN modules. If you are stringifying hashes for comparison purposes make sure you apply a sort to the keys first.

        I was under the impression that the order of unsorted hash keys is not even guaranteed for *each invocation* of perl for any version of perl in any environment ...

        # Perl 5.8.7, perldoc -f keys keys HASH ... The keys are returned in an apparently random order. The actual random order is subject to change in future versions of perl, but it is guaranteed to be the same order as either the "values" or "each" function produces (given that the hash has not been modified). Since Perl 5.8.1 the ordering is different even between different runs of Perl for security reasons (see "Algorithmic Complexity Attacks" in perlsec). ...

        ... ok, at least not since version 5.8.1.