So I've been attempting to find the solution to this but so far everything I've read online has to do with scope issues and not declaring the variables with the my keyword. However, I can't seem to fix the issues because I've declared everything at the top and, to me at least, it seems I don't have scope issues. My errors for the following code are:
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.
The code:
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";