Object Reference

Jason White jasona at inetarena.com
Fri Jul 19 20:29:26 CDT 2002

I'm using Data::Dumper to save and restore objects.

Here is my RestoreFromFile function.

sub RestoreFromFile($){
        my ($filename,$tmp,$VAR1);
        open(INFILE, "$filename");
        eval $tmp;
        return $VAR1; # returns a reference to an object
# Why does Data::Dumper format the dump so nicely?  
# I'm going to have to strip out all the newlines before writing to make this more useful

my $tmp = RestoreFromFile("objectfile");

I now have a pointer to my object($tmp) but how do I typedef it or anothr variable to the right object type?
$tmp->ObjectMethod() doesn't work, it thinks I'm trying to invoke a method of a scalar (the reference) not the object type.

Jason White

P.S.  There has to be a better serialization strategy, doesn't there?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/pdx-pm-list/attachments/20020719/f99277a6/attachment.htm

More information about the Pdx-pm-list mailing list