I’ve written the Perl script below which generates a warning and I can’t work out why.
#!/usr/local/bin/perl -w
$status = $ENV{ 'STATUS' };
if ( $status eq "" )
{
$status = 0;
}
else
{
$status = 1;
}
It says "Use of uninitialized value in string eq at ./x.pl line 4."
Line 4 is the "if ( $status eq "" )" line, but the variable was initialised…
How can I get rid of this warning?
$ENV{'STATUS'}may not be defined.If you run
in the shell before running the Perl script, it will work.
Fix it with