in reply to Re: Re: A vexing list vs. scalar context question.
in thread A vexing list vs. scalar context question.
if (wantarray) { # handle scalars too! return $self->{$x} if not ref $self->{$x}; # handle arrays return @{ $self->{$x} } if ref $self->{$x} eq 'ARRAY'; # handle hashes return %{ $self->{$x} } if ref $self->{$x} eq 'HASH'; # panic! die "unknown reference type (", ref($self->{$x}), ")"; } else { return $self->{$x} }
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: A vexing list vs. scalar context question.
by tye (Sage) on Feb 01, 2002 at 00:51 UTC | |
by japhy (Canon) on Feb 01, 2002 at 02:06 UTC | |
by tye (Sage) on Feb 01, 2002 at 07:13 UTC | |
by chipmunk (Parson) on Feb 01, 2002 at 02:42 UTC | |
by theorbtwo (Prior) on Feb 01, 2002 at 04:35 UTC |