G
geek
Hi all,
I am getting this error in my perl script at the line "else {stat()"
See the code at the bottom.
Any help will be appreciated.
Thanks,
MJ
########################################################
if( param('Get')){ date();}
else { stat();}
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){
@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;
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 $avg;
my $finalAvg=0;
open(handGrade,"./gradeFile") or die "gradeFile cannot be opened";
my @avgarr = <handGrade>;
my $tmpAvg;
foreach $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";
}
###########################################################################
I am getting this error in my perl script at the line "else {stat()"
See the code at the bottom.
Any help will be appreciated.
Thanks,
MJ
########################################################
if( param('Get')){ date();}
else { stat();}
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){
@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;
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 $avg;
my $finalAvg=0;
open(handGrade,"./gradeFile") or die "gradeFile cannot be opened";
my @avgarr = <handGrade>;
my $tmpAvg;
foreach $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";
}
###########################################################################