Error "Use of uninitialized value "

G

geek

Hi all,

I am getting the error of "Use of uninitialized value" in the line
"else { stat();}"

Any help will be appreciated. Look at the bottom for the code .

#########################################################
sub stat {
print header(), start_html("The Statistics for Administrator");
open(fileHandle,"./outputFile") or die "The file cannot be opened";
my @fileData = <fileHandle>;
my $count1=0;
my $count2=0;
my $count3=0;
my $count4=0;
my $count5=0;
my $count6=0;
my $count7=0;
my $count8=0;
my $count9=0;
my $countt=0;
# my @array;
foreach my $word(@fileData){
print "******$word";
my @array=split(/ /, $word);

foreach my $element(@array){
if($element eq "CS5375"){
$count1++;
}
if($element eq "cd"){
$count2++;
}
if($element eq "cp"){
$count3++;
}
if($element eq "vim"){
$count4++;
}
if($element eq "%ls-l"){
$count5++;
}
if($element eq "man"){
$count6++;
}
if($element eq "perl-v"){
$count7++;
}
if($element eq "all"){
$count8++;
}
if($element eq "finger"){
$count9++;
}
if($element eq "ftp\n"){
$countt++;
# print "hello";
}
}
}

my $noLine=0;
open( fileHandle,"<./outputFile");
$noLine++ while <fileHandle>;
print "Number of lines in the file is $noLine";
my $noUsers= $noLine/2;
print br;
print "Number of users is $noUsers";
print br;
my $finalAvg=0;
open(handGrade,"./gradeFile") or die "gradeFile cannot be opened";
my @avgarr = <handGrade>;
my $tmpAvg;
foreach my $avg(@avgarr){
$tmpAvg="$finalAvg"+"$avg";
$finalAvg=$tmpAvg/2;
}
print "The average is $finalAvg";
print br;
my $percentage1=($count1/$noUsers)*100;
print " The percentage for first question is $percentage1";
my $percentage2=($count2/$noUsers)*100;
print br;
#####################################################################
 
J

John Bokma

geek said:
Hi all,

I am getting the error of "Use of uninitialized value" in the line
"else { stat();}"

yes.

I can give you one advice: stop writing (CGI) scripts until you have read
at least two books on Perl.
 
X

xhoster

geek said:
Hi all,

I am getting the error of "Use of uninitialized value" in the line
"else { stat();}"

Any help will be appreciated. Look at the bottom for the code .

That line does not appear in your code.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top