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;
#####################################################################
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;
#####################################################################