slloyd has asked for the wisdom of the Perl Monks concerning the following question:
use strict; my $txt=callMe(1,2,3); print "txt=$txt\n"; my @tmp=callMe(1,2,3); print "tmp=@tmp\n"; my %list=callMe(1,2,3); foreach my $key (keys(%list)){print "list{$key}=$list{$key}\n";} sub callMe{ my @in=@_; if(wantarray){ #how do I determine if the caller wants an array or a hash? return reverse(@in); } else{return join(",",reverse(@in));} }
--------------------
txt=3,2,1
tmp=3 2 1
list{1}=
list{3}=2
-------------------------------
by me
http://www.basgetti.com
http://www.kidlins.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: wantarray like wanthash
by dragonchild (Archbishop) on Dec 12, 2005 at 21:03 UTC | |
|
Re: wantarray like wanthash
by Roy Johnson (Monsignor) on Dec 12, 2005 at 21:02 UTC | |
|
Re: wantarray like wanthash
by Fletch (Bishop) on Dec 12, 2005 at 21:03 UTC | |
|
Re: wantarray like wanthash
by GrandFather (Saint) on Dec 12, 2005 at 21:15 UTC | |
|
Re: wantarray like wanthash
by jZed (Prior) on Dec 12, 2005 at 21:34 UTC |