我试图运行下面索引数组
Use of uninitialized value within @words in concatenation (.) or string...
它引用在这里我尝试创建由三数组行代码时,得到的Perl以下错误,当“未初始化值使用”单词序列(以$trigrams
开头的行)。任何人都可以帮我弄清楚这个问题吗?
my %hash;
my @words;
my $word;
my @trigrams;
my $i = 0;
while (<>) {
@words = split;
foreach $word (@words) {
$hash{$word}++;
# Now trying to create the distinct six-grams in the 10-K.
$trigrams[$i] = join " ", $words[$i], $words[$i + 1], $words[$i + 2];
print "$words[$i]\n";
$i++;
}
}
始终'使用严格的;使用警告;'! – Biffen 2014-09-05 21:07:00
当'$ i'是最后一个(或倒数第二个)时,看起来像'$ words'带有'$ words [$ i + 1]'和'$ words [$ i + 2]'' )指数。 – Biffen 2014-09-05 21:10:21