Question

How would I solve the following in error in my code:

Use of uninitialized value in scalar assignment at faStat2 line 59.

#!/usr/bin/perl
use strict;
use warnings;

...

$~ = *OUTFILE; #This is the line it is complaining about
my $cmd = $0;
$cmd =~ s#.*/##;
Was it helpful?

Solution

OUTFILE should be in single quotes because without them it is a bareword and with the * in front of it it is seen as an item requiring scalar. The code should look like:

#!/usr/bin/perl
use strict;
use warnings;

...

$~ = 'OUTFILE';
my $cmd = $0;
$cmd =~ s#.*/##;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top