in reply to Re: Confused Contexts and wantarray
in thread Confused Contexts and wantarray

Hi folks, New to 'monks but not Perl. I've used it (wantarray) very effectively (>5.6.1, probably well before) in this way.
sub func { my(...) = @_; my @new_a; # assume some assignment to @new_a based on params for(....) {} wantarray? @new_a: \@new_a; } # this one gets you a reference to @new_a in &func() # which is available as long as $ar_array is in scope my $ar_array = &func(...); # this is the copy of @new_a from &func() # @new_a is gone my @array = &func(...); Also: wantarray? @foo: "@foo" wantarray? @foo: $foo[0] aren't nearly the same except the first above is an implicit join to scalar and the second is the first element which may or may not be what you want.
Please contact me: morourke@theworld.com