This error message is printed when a nondeclared variable is used in the code running under the strict pragma. For example, consider the short script below, which contains a use strict; pragma and then shamelessly violates it:
#!/usr/bin/perl -w use strict; print "Content-type: text/html\n\n"; print "Hello $username";
Since Perl will insist that all variables are defined before being used, the program will not run and will print the error:
Global symbol "$username" requires explicit package name at /home/httpd/perl/tmp.pl line 4.
Moreover, in certain situations (e.g., when SIG{_ _DIE_ _} is set to Carp::confess( )) the entire script is printed to the error_log file as code that the server has tried to evaluate, so if this script is run repeatedly, the error_log file will grow very fast and you may run out of disk space.
This problem can easily be avoided by always declaring variables before using them. Here is the fixed version of our example:
#!/usr/bin/perl -w use strict; my $username = ''; print "Content-type: text/html\n\n"; print "Hello $username";
 
Continue to: