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