下面的代码提供了错误:全局符号“$地”需要在main.pl线19
#!/usr/local/bin/perl
use strict;
use warnings;
my @ground=();
sub map_gen{
my $width=10;
my $height=10;
foreach my $x(0..$width){
foreach my $y(0..$height){
[email protected]{$ground[$x]},"-";
}
}
}
&map_gen;
foreach my $y([email protected]{$ground}){
foreach my $x([email protected]{$ground[$y]}){
print $ground[$x][$y];
}
print"\n";
}
我研究这个错误,明确包名这是由于引用了一个未声明的变量,但是我在错误出现之前声明了@ground。我怀疑这是因为它是一个标量引用,但不知道如何纠正它。
旁注;喜欢'map_gen();'over'&map_gen;'=> http://stackoverflow.com/questions/8912049/difference-between-function-and-function-in-perl –
@mpapec:把超链接放入评论使用'文本](http:// ...)' – Borodin