Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Should I use Fields, InsideOuts, or Properties?

by larard (Monk)
on Jul 06, 2005 at 14:25 UTC ( #472815=note: print w/replies, xml ) Need Help??

in reply to Should I use Fields, InsideOuts, or Properties?

Not to add to your choices, but whenever I am faced with this I use Hash::Util's lock_keys method as follows....
package Dog; use Hash::Util qw(lock_keys); use Data::Dumper; sub new { my $pkg = shift; my $ref = {}; bless $ref, $pkg; lock_keys(%$ref,qw(intelligence)); $ref->{intelligence} = shift; $ref; } sub is_stupid { my $self = shift; return $self->{inteligence} < 3; } my $lassie = Dog->new(10); print Dumper($lassie); print "Lassie is ", $lassie->is_stupid ? "dumb" : "smart";
In the case of subclassing this, it should be easy enough to call unlock_keys, do what you need, and then lock it again.

This novice wasn't aware of the other methods you mention for achieving this, and would be interested in hearing what other monks might say of the methods described here.

Of course this only gives one runtime checks, but those are sufficient for my purposes.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://472815]
marioroy just logged in to say that MCE::Hobo has passed testing and therefore will continue to run like threads but have managed capabilities similar to Parallel:: ForkManager. It allows multiple managed instances to run simultaneously. Zero limitations.
marioroy it's taken a long time to make this possible.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2017-07-28 19:42 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (433 votes). Check out past polls.