in reply to setting and retrieving sub-hash elements in an object

Untested:
sub option { my $self=shift; die unless @_; if (@_ == 1) { return $self->{options}->{+shift}; } my %h=@_; @{$self->{options}}{keys %h}=values %h; }
If you want to play with @_ as though it were a hash, I don't think you can get away without a temp hash (%h) without using an explicit loop (or two) like this:
while(@_) { $self->{options}->{+shift}=shift; }

Replies are listed 'Best First'.
Re (tilly) 1: setting and retrieving sub-hash elements in an object
by tilly (Archbishop) on Dec 17, 2001 at 02:54 UTC
    Actually there is a way to avoid the explicit loop, but it is a little inefficient:
    sub option { my $self = shift; if (1 == @_) { return $self->{option}->{ shift(@_) }; } else { %{$self->{option}} = (%{$self->{option}}, @_); } }