in reply to setting and retrieving sub-hash elements in an object
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:sub option { my $self=shift; die unless @_; if (@_ == 1) { return $self->{options}->{+shift}; } my %h=@_; @{$self->{options}}{keys %h}=values %h; }
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 |