I’m using Perl’s Calendar module to create a “date”, and I want to serialize this data to a text file and then get it back.
I’m trying to use FreezeThaw to accomplish this. Thus, this is what I have so far:
my $date = Calendar->new_from_Gregorian((localtime)[4] + 1, (localtime)[3], (localtime)[5]+1900);
$string = freeze $date;
print $string."\n";
$olddata = thaw $string;
print $olddata->date_string."\n";
And I get back:
FrT;@1|>>0|$19|Calendar::Gregorian%8|$8|absolute$3|day$5|month$4|year$6|734599$1|6$1|4$4|2012
Can't call method "date_string" on an undefined value at calendar.pl line 23.
My question is: how do I get the thawed value back into a usable Calendar object, so that I can call methods like $olddata->date_string?
You need to call
thawin list context. This can be achieved by changingto
I have just filed a bug report concerning this questionable need.