in reply to Re: Fastest data structure compare?
in thread Fastest data structure compare?

Storable warns against this
if you happen to use your numbers as strings between two freezing operations on the same data structures, you will get different results.

There is no facility either to return all strings as utf8 sequences, or to attempt to convert utf8 data back to 8 bit and croak() if the conversion fails.

It is easily avoided if you use encoding/Encode

Replies are listed 'Best First'.
Re^3: Fastest data structure compare?
by eserte (Deacon) on Oct 08, 2009 at 12:43 UTC
    Encode may help in the utf8 case, but not in the case of different integer representation (as mentioned in the Storable manpage):
    #!/usr/bin/perl use Data::Compare qw(); use Storable qw(nfreeze); use Test::More qw(no_plan); my $data1 = { foobar => 1 }; my $data2 = { foobar => "1" }; $Storable::canonical = 1; is_deeply($data1, $data2, "is_deeply test"); ok(Data::Compare::Compare($data1, $data2), "Data::Compare"); ok(nfreeze($data1) eq nfreeze($data2), "storable serialized");
      Great, you've read the bug section :)