in reply to dynamic 2d array
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];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: dynamic 2d array
by Anonymous Monk on Aug 14, 2008 at 03:45 UTC | |
by amarquis (Curate) on Aug 14, 2008 at 13:45 UTC |