The two main issues have already been stated, not defined yet and use strict.
However, I'd also add that you avoid using global and instead pass parameters to your functions. If you did that, it would be much more obvious that a data structure is not defined yet when you make our function call.
#!c:\strawberry\perl\bin\perl.exe -w use strict; my @test = ( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], ); displayBoard(@test); sub displayBoard { foreach ( @_ ) { print "@$_\n"; } }
In reply to Re: I can't figure out what's wrong with this foreach loop
by wind
in thread I can't figure out what's wrong with this foreach loop
by bryan172
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |