Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: General Class Creation Using Persistent Object, Method Privacy Enforcement and Exceptions

by DeadPoet (Scribe)
on Jun 30, 2003 at 14:56 UTC ( #270184=note: print w/ replies, xml ) Need Help??


in reply to Re: General Class Creation Using Persistent Object, Method Privacy Enforcement and Exceptions
in thread General Class Creation Using Persistent Object, Method Privacy Enforcement and Exceptions

Thanks, I missed the fact that I had hard coded the store file name but had passed the reference to the file name. The sub store_object {} should read as follows:

sub store_object { my ( $self, $sref_file ) = @_; # Caller Check my $return = $self->_caller_check(); if ( $return ) { print STDERR $$return . "\n"; return $return; } Storable::store ( \%{ $self }, $$sref_file ); return undef; }

Peace Out,

DeadPoet


Comment on Re: Re: General Class Creation Using Persistent Object, Method Privacy Enforcement and Exceptions
Select or Download Code
Replies are listed 'Best First'.
Re: Re: Re: General Class Creation Using Persistent Object, Method Privacy Enforcement and Exceptions
by Anonymous Monk on Jul 01, 2003 at 18:54 UTC
    Why write \%{$self}? It's a waste of both space and execution time for your code (perl may optimize it, but it's still a waste of space...) Instead, use $self, which is the exact same thing, and makes it obvious that you're putting a blessed object into the file (it took me a while to comprehend that \%{$self} somehow kept the object blessed and returned $self, itself-- this is completely countra-my previous knowledge of perl. Could somebody explain why that works?)
      I agree. \%{$self} takes about five minutes to type. $self takes 1.618033989 seconds to type(I timed it.) To use an analogy, 1.618033989 is a lot easier than writing {sqrt(5) + 1}/2. And phi is easier still. As the author of "Walden Pond" asserted concisely, "Simplify, simplify." -100104
      After evaluating the difference between \%{ $self } and $self, I see that you are correct. I see that I am making perl perform a dereference to the same memory location. I will make corrections in my code. Thanks for the input.

      Peace Out,

      DeadPoet

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://270184]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (18)
As of 2015-07-30 18:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls