I have troubles using a function in Perl.
My function has 2 arguments which are arrays :
sub get_coordinate {
my (@array_col, @array_lin) = (@_);
do some stuff
}
I call it this way :
$index_col = int(rand(10));
$index_lin = int(rand(10));
@array_col = (0,0,0,0,0,0,0,0,0,0);
@array_lin = (0,0,0,0,0,0,0,0,0,0);
$array_col[$index_col] = 1;
$array_lin[$index_lin] = 1;
get_coordinate(@array_col, @array_lin);
My problem is that I get the error message : Use of uninitialized value within @array_lin in numeric eq (==) at switch.pl line 82 (#1) (W uninitialized) An undefined value was used as if it were already defined. It was interpreted as a "" or a 0, but maybe it was a mistake. To suppress this warning assign a defined value to your variables.
I don't understand why @array_col is initialized an not @array_lin.
When I print @array_col and @array_lin inside the function this way :
print "@array_col\n@array_lin\n";
I get : 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0
Any idea ?
Thx, SLP
get_coordinate(\@array_col, \@array_lin)