Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Death to auto-vivification

by bobf (Monsignor)
on Mar 03, 2008 at 19:21 UTC ( [id://671695]=note: print w/replies, xml ) Need Help??


in reply to Death to auto-vivification

You may find Hash::Util or Readonly interesting. I haven't used either but I'm sure other monks could chime in on their pros and cons. A Super Search might point you in the right direction, too.

Replies are listed 'Best First'.
Re^2: Death to auto-vivification
by doom (Deacon) on Mar 04, 2008 at 06:38 UTC
    I'm a fan of Hash::Util when working with hash-based objects, myself. I tend to use init routines that look like this (to make it impossible to accidentally create a hashkey that's not supposed to be there):
    use Hash::Util qw( lock_keys unlock_keys ); sub init { my $self = shift; my $args = shift; unlock_keys( %{ $self } ); my @attributes = qw( something_or_other another_something ); foreach my $field (@attributes) { $ATTRIBUTES{ $field } = 1; $self->{ $field } = $args->{ $field }; } lock_keys( %{ $self } ); return $self; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-18 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found