Winston said:
Why this is not work?
@array=@_[2..$#_-1];
I give to a function 2 variables and 1 array, y need to take the whole
array.
Taking another look at this, I think *maybe* I understand what you're
asking. My *guess* is that you have the above line in your subroutine,
and you are passing that subroutine two scalars followed by an array.
And you're expecting @array to contain all the elements of the array
you passed to the subroutine. But it's missing the final element.
Is my guess correct?
If so, your actual problem is not realizing that $#_ is the last
*index* of @_, not the size. Therefore, you should not be subtracting
1 from it. Remove "-1" and it will do what you want.
In reality, however, that's an awful piece of code, and you should
trash it immediately. Does your subroutine look something like this?
sub fctn {
my $foo = $_[0];
my $bar = $_[1];
my @baz = @_[2..$#baz];
# ...
}
If so, please replace it with:
sub fctn {
my ($foo, $bar, @baz) = @_;
#...
}
Hope this helps,
Paul Lalli