in reply to Multiple Return Values
The code I use looks like this:
except that %opts actually contains references to "get" methods.my @opts= qw( This That TheOther Else Foo Bar Blatz ); my %opts; @opts{@opts}= 1x@opts; sub GetOptions { my $self= shift(@_); my $href= {}; $href= shift(@_) if @_ && UNIVERSAL::isa($_[0],"HASH"); @_= @opts if ! @_; foreach my $opt ( @_ ) { croak ref($self),"->GetOptions: Invalid option ($opt) ", "not one of ( @opts )" unless $opts{$opt}; $href->{$opt}= $self->Get($opt); } return @{$href}{@_}; }
For your helper code I suggest this change:
or just use a hash slice directly in the caller. - tye (but my friends call me "Tye")sub _populate_hash { my $hvHash= shift(@_); my $avValues= shift(@_); my $avNames= shift(@_); croak unless @$avValues == @$avNames; @{$hvHash}{@$avNames}= @$avValues; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: Multiple Return Values
by John M. Dlugosz (Monsignor) on Jul 12, 2001 at 01:26 UTC | |
by tye (Sage) on Jul 12, 2001 at 01:53 UTC |