Thread Problem mit Storable
(7 answers)
Opened by Jan at 2015-11-10 15:17
Wenn du nicht weiter enttäuscht werden willst, nimm Sereal.
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 use Path::Tiny qw(path); use Sereal::Encoder qw(encode_sereal SRL_SNAPPY); use Sereal::Decoder qw(decode_sereal); use Test::More; use Test::Deep qw(cmp_deeply); my @categories = 1..100; my $categoriesFile = glob "~/categories.sereal"; { my $path = path($categoriesFile); $path->filehandle({exclusive => 1}, '>'); $path->spew_raw(encode_sereal \@categories, { compress => SRL_SNAPPY, croak_on_bless => 1 }); } { my $path = path($categoriesFile); $path->filehandle({exclusive => 1}, '<'); my @categories2 = decode_sereal($path->slurp_raw, { refuse_objects => 1, validate_utf8 => 1 })->@*; cmp_deeply \@categories, \@categories2; } done_testing; |