Use of uninitialized value in read at access-roll.cgi line 39.
Use of uninitialized value in split at access-roll.cgi line 46.
Use of uninitialized value in string eq at access-roll.cgi line 13.
Lines in question marked with >>>>
###############################################
#!/usr/bin/perl -w
use vars qw(%config %form %02d);
use CGI;
use File::Copy;
local %config;
$config{'basepath'} = '/home/mysite';
$config{'closedir'} = '/home/mysite/access';
require "/home/mysite/access/next.dat";
$nowtime = (time);
$log = 'access-log';
######## Main Program
local %form = &get_form_data;
if ($form{'action'} eq '') { &closeit; } >>>>
else { &closeit; }
#-###################
sub closeit {
open (NEXT, "$config{'closedir'}/next.dat");
($item) = <NEXT>;
close NEXT;
if ($item < $nowtime) {
$nextroll = ($item + 86400);
if ($config{'closedir'}) {
umask(000);
mkdir("$config{'closedir'}", 0777) unless (-d "$config{'closedir'}");
copy ("$config{'basepath'}/$log", "$config{'closedir'}/$item.txt");
open (NEW, ">$config{'basepath'}/$log");
print NEW "";
close NEW;
open (NEXT, ">$config{'closedir'}/next.dat");
print NEXT "$nextroll";
close NEXT;
}
}}
#-#####################
sub get_form_data {
my $temp;
my $buffer;
my @data;
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); >>>>
foreach $temp (split(/&Š=/,$buffer)) {
$temp =~ tr/+/ /;
$temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
$temp =~ s/[\r\n]/ /g;
push @data, $temp;
}
foreach $temp (split(/&Š=/,$ENV{'QUERY_STRING'})) { >>>>
$temp =~ tr/+/ /;
$temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
$temp =~ s/[\r\n]/ /g;
push @data, $temp;
}
return @data;
}
###############################################
There may be code that I don't need? but I'm not too sure what isn't needed.
Any help appreciated.
It seems that youŽll get those warnings if there is no input from STDIN. To exit immediately at the beginning of your script unless $ENV{'CONTENT_LENGTH'} is defined might help.
Andreas
Just a word of advice: While developing your script use the -w switch. It will be really helpful. Once you tested your scripts and they work ok remove the -w on your production system.
Yet a better way would be to exit your script immediately if there is no valid input and avoid the warnings this way.
Andreas