1
所以我一直試圖找到解決這一點,但到目前爲止一切,我在網上看了有做與範圍問題,而不是與我聲明變量關鍵詞。然而,我似乎無法解決這些問題,因爲我已經宣佈了所有的問題,至少對我來說,似乎我沒有範圍問題。我對下面的代碼錯誤是:的Perl:全局符號需要明確包名稱
Global symbol "$filename" requires explicit package name at read_ids.pl line 6.
Global symbol "$filename" requires explicit package name at read_ids.pl line 8.
Global symbol "$filename" requires explicit package name at read_ids.pl line 9.
Global symbol "$filename" requires explicit package name at read_ids.pl line 22.
代碼:
use strict;
use warnings;
#Create array of IDs.
my @ids
my $filename = 'ids.csv';
open(my $fh, '<:encoding(UTF-8)', $filename)
or die "Could not open file '$filename'.";
#Read line using the readline operators <>.
while (my $row = <$fh>) {
#Remove any newline characters from line using the chomp() command.
chomp $row;
push @ids,'$row';
# print "$row\n";
}
foreach (@ids) {
print "$_\n";
}
print "Read '$filename' successfully.\n";
你錯過了;在我的@ids之後。它應該是我的@ids; – Rajarshi