What I am doing wrong? Opened file is not empty. But I'm still getting
Global symbol "$tabbb" requires explicit package name at mix.pl line 8.
#!/usr/bin/perl
use strict;
use warnings;
open FILE, "<", "seeds.data" or die $!;
my @tab = <FILE>;
print @$tab;
you want
print @tab;
instead ofprint @$tab;
.You have correctly used
use strict
anduse warnings
, and one of the benefits is that Perl will warn you if you use a variable you haven't declared. The error messageis saying that, because you are using
strict
, you cannot refer to a variable called$tabbb
that hasn't been declared. Your lineis dereferencing the scalar variable
$tab
as an array, and since you haven't declared a$tab
I imagine that is what the error message means. However you do have an array variable@tab
that contains the contents of the file you opened, so writeinstead.
Best of all, read the file line-by-line and write