Object IO (Typedef problem)
jasona at inetarena.com
Mon Jul 22 19:14:34 CDT 2002
Thank you Randal, I am now using Storable.
I am still pretty much in the same boat however. I can't find any perl documentation on how to typedef a reference to a custom object. I have a package which I've named PDX::service. When I store and retrieve an instance of PDX::service I am left with a reference. I know how to typedef a reference to a scalar, array, or hash, however, I do no know how to typedef the reference to be of type PDX::service.
I've made pitiful attampts such as PDX::service$objref->method() and $$objref->method() to no avail.
ref($objectref) returns main.
ref($$objectref) returns PDX::service
This makes me think that THIS is the appropriate way to access this object:
This returns no errors, like my other attempts did, however, it retuned no data either. Does retrive() is it possible that my retrieved object has members but no methods and doesn't "truly" belong to type PDX::service?
>From merlyn at stonehenge.com Mon Jul 22 14:41:48 2002
Date: 17 Jul 2002 23:32:09 -0700
From: Randal L. Schwartz <merlyn at stonehenge.com>
To: Jason White <jasona at inetarena.com>
Cc: perl <pdx-pm-list at pm.org>
Subject: Re: Object IO
>>>>>>>>>> "Jason" == Jason White <jasona at inetarena.com> writes:
Jason> What is the best method to read and write objects from file?
Jason> Should I serialize the object? I've heard Data::Dumper
Jason> mentioned for saving hashes, is it good for this purpose as
Data::Dumper does too much work, making Perl code on the way out, and
then having to eval it on the way in.
My favorite is Storable, now part of the Perl core, but easily found
in the CPAN for older Perls.
Also look into Tie::MLDBM, which gives an indexed way to partition a
file, using Storable automatically to store and retrieve complex
If you want something more interesting, look at Tangram, which
provides an object to relational-database mapping.
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
More information about the Pdx-pm-list