Amoe has asked for the wisdom of the Perl Monks concerning the following question:
bless {foo => 'bar', options => {anoption => 1, anotheroption => 'foo', option3 => 'barbar'}, bar => 'maz'}, $class;
This works, but looks cumbersome. There has to be an easier way to do it. I think I need to be clearer on hash assignment in general, as well. I always thought that you say this:sub option { my $self = shift; if (scalar @_ == 1) { return $self->{options}->{shift()}; } else { my ($key, $value) = @_; $self->{options}->{$key} = $value; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
(jeffa) Re: setting and retrieving sub-hash elements in an object
by jeffa (Bishop) on Dec 17, 2001 at 02:03 UTC | |
Re: setting and retrieving sub-hash elements in an object
by Masem (Monsignor) on Dec 17, 2001 at 02:04 UTC | |
Re: setting and retrieving sub-hash elements in an object
by Aristotle (Chancellor) on Dec 17, 2001 at 04:29 UTC | |
Re: setting and retrieving sub-hash elements in an object
by Ven'Tatsu (Deacon) on Dec 17, 2001 at 02:55 UTC | |
Re: setting and retrieving sub-hash elements in an object
by clintp (Curate) on Dec 17, 2001 at 02:05 UTC | |
by tilly (Archbishop) on Dec 17, 2001 at 02:54 UTC |