>>>>> "IB" == Ingo Blechschmidt <[EMAIL PROTECTED]> writes:
IB> * "(key => $value)" (with the parens) is always a positionally passed
IB> Pair object. "key => $value" (without the parens) is a named
IB> parameter:
IB> sub foo ($a) {...}
IB> * Unary "*" makes a normal pair variable participate in named binding:
IB> foo(*$pair); # named parameter "a", $a will be 42
IB> * Same for hashes:
IB> my %hash = (a => 1, b => 2, c => 3);
IB> foo(%hash); # positional parameter, $a will be \%hash
IB> foo(*%hash); # three named parameters
IB> Opinions?
works for me. but what about lists and arrays?
my @z = ( 'a', 1 ) ;
foo( @z ) # $a = [ 'a', 1 ] ??
my @z = ( a => 1 ) ;
foo( @z ) # $a = pair( a => 1 ) or does that need * too?
same questions for lists (this shows a nested sub call)
sub bar { return ( a => 1 ) }
foo( bar() ) # i would expect $a == ( a => 1 ) since there is
# no *
foo( *bar() ) # i would expect $a == 1
i think i covered most/all of the variations. but this needs to be
hammered down for all of them.
thanx,
uri
--
Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org