I am getting the below perl error.
Can't use string ("") as a symbol ref while "strict refs" in use at test173 line 30.
Pasted the code below. Line 30 is the open statement. It’s failing
in the open statement. I have use strict; and use warnings; in the
script. What does the error denote? How do I change the code to resolve
this error.
my $file = 'testdata';
open($data, '<', $file) or die "Could not open '$file'\n";
print "file data id:$data\n";
@iu_data = <$data>;
$totalLineCnt = @iu_data;
print "total line cnt: $totalLineCnt". "\n";
Be sure that you did not assign a value to $data before. I can reproduce your problem by just three lines:
You can resolve the problem for example by creating a new scope:
Alternatively, you can undefine
$databefore using it:Etc, etc…