#!/usr/bin/perl -w
use strict;
use IO::File;
use Data::Serializer;
use Data::Dumper;
my @list;
my $s = Data::Serializer->new(
serializer => 'Storable',
portable => 0,
compress => 0,
);
if (-s "./list.bin") {
print "Load ice and thaw\n";
my $f = new IO::File "./list.bin", "r" or die;
my $ice = do { local $/; <$f> };
@list = @{$s->thaw($ice)};
print Dumper(\@list);
} else {
print "Build list and freeze\n";
@list = qw/ 0 1 2 3 /;
my $ice = $s->freeze(\@list);
my $f = new IO::File "./list.bin", "w" or die;
print $f $ice;
}
|