On 7/26/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
> Hi,
>
> are the following assumptions correct?
>
> sub foo ([EMAIL PROTECTED]) { @args[0] }
>
> say ~foo("a", "b", "c"); # "a"
Yep.
> my @array = <a b c d>;
> say ~foo(@array); # "a b c d" (or "a"?)
> say ~foo(@array, "z"); # "a b c d" (or "a"?)
"a" for both of these. The *@ area behaves just like Perl 5's calling
conventions. I could argue for never auto flattening arrays, but then
there'd really be no difference between @ and $.
> say ~foo([EMAIL PROTECTED]); # "a"
> say ~foo(*(@array, "z")); # "a"
Hmm, *(@array, "z")... what does that mean? Whatever it means, you're
correct in both of these. In the latter, the @array is in a
flattening context, so it gets, well, flattened.
> sub bar ([EMAIL PROTECTED]) { [EMAIL PROTECTED] }
>
> say bar(1,2,3); # 3
> say bar(@array); # 1 (or 4?)
4
> say bar(@array, "z"); # 2 (or 5?)
5
> say bar([EMAIL PROTECTED]); # 4
Yep.
Luke