in reply to passing an array

Just to expand on the above answers. In your example you pass arg1, $arg2, $arg3, $ar4, @data to the sub. What @_ gets is
$_[0] = $arg1, $_[1] = $arg2, $_[2] = $arg3, $_[3] = $arg4, $_[4] = $data[0], $_[5] = $data[1]
So you can see by the above what is happening.

The ways to do this are as mentioned above, pass a reference to the array and dereference it, or assign all of the arguments to variables and then assign the rest of the @_ array to @info..

Update: per merlyn's comments below, have updated appropriately. Normally I would have written it like that, really not sure why I didn't in this case.

Replies are listed 'Best First'.
Re: Re: passing an array
by merlyn (Sage) on Mar 28, 2001 at 18:51 UTC
    Ouch. Please. @foo[0] hurts my eyes. Surely you meant to say:
    $_[0] = $arg1, $_[1] = $arg2, $_[2] = $arg3, $_[3] = $arg4, $_[4] = $data[0], $_[5] = $data[1]
    A single-element slice is almost never what people want. Warnings-on would have told you that.

    -- Randal L. Schwartz, Perl hacker