my variables are defined strictly lexical. That means d_array is only defined and known after line 23, but not in line 10 where you already use it. Move the line 'my d_array;' before the subroutine definition and it should work. Even better would be to give the array to the subroutine as a parameter:
sub printRow{ #input the row number print Dumper(@_); } # and later: &printRow(@d_array);
By the way, your for-loop can be replaced by this simple line:
$d_array[$line_number]= [@field];
In reply to Re: dynamic 2d array
by jethro
in thread dynamic 2d array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |