i could not read from the dat file if there is anything wrong with the if statment i can fix it put what is wrong with reading and writing to the file please
use CGI qwstandard);
print header();
print start_html("CGI-Perl Programming voting response" .
" Response, using CGI.pm"
# read input fields from the html page
my $firstn = param("First"
my $lastn = param("Last"
my $lang = param("language"
# open and lock the file
open(PL,"<hh.dat"
flock(PL, 2);
# read the count from the file
$count = <PL>;
chomp ($count);
{
@array = split(/ /,$count); <<<< somthing is wrong here
}
$C_count = $array[0]; <<<< if i try this with jsut perl
$Java_count = $array[1]; <<<< interpter it works just this part
$Ada_count = $array[2];
$Perl_count = $array[3];
$Cobol_count = $array[4];
$Fortran_count = $array[5];
print "$C_count"; <<<< here i just want to see if i can get
reply with the correct no put it is wrong
if ($lang == "C"
{
$C_count =$array[0]+1;
}
else
{
$C_count =$array[0];
}
if ($lang == "Java"
{
$Java_count =$array[1]+1;
}
else
{
$Java_count =$array[1];
}
if ($lang == "Ada"
{
$Ada_count =$array[2]+1;
}
else
{
$Ada_count =$array[2];
}
if ($lang == "Perl"
{
$Perl_count =$array[3]+1;
}
else
{
$Perl_count =$array[3];
}
if ($lang == "Cobol"
{
$Cobol_count =$array[4]+1;
}
else
{
$Cobol_count =$array[4];
}
if ($lang == "Fortran"
{
$Fortran_count =$array[5]+1;
}
else
{
$Fortran_count =$array[5];
}
flock (PL,8);
close (PL);
# reopen and write to the file --
open(PL,">plsurv.dat"
flock(PL,2);
print PL "$C_count $Java_count $Ada_count $Perl_count $Cobol_count $Fortran_count";
flock(PL,8);
close (PL);
print "$C_count"; <<<here too wrong response
print "<h3>";
print "Thanks $firstn , for your input !";
print "</h3>";
print br;print br;
print "</h2>";
print "here is the votes";
print "</h2>";
print br;
print " C/C++ : $C_count" ;
print br;
print " Java : $Java_count" ;
print br;
print " Ada : $Ada_count" ;
print br;
print " Perl : $Perl_count" ;
print br;
print " Cobol : $Cobol_count" ;
print br;
print " Fortran : $Fortran_count" ;
print end_html;
use CGI qwstandard);
print header();
print start_html("CGI-Perl Programming voting response" .
" Response, using CGI.pm"
# read input fields from the html page
my $firstn = param("First"
my $lastn = param("Last"
my $lang = param("language"
# open and lock the file
open(PL,"<hh.dat"
flock(PL, 2);
# read the count from the file
$count = <PL>;
chomp ($count);
{
@array = split(/ /,$count); <<<< somthing is wrong here
}
$C_count = $array[0]; <<<< if i try this with jsut perl
$Java_count = $array[1]; <<<< interpter it works just this part
$Ada_count = $array[2];
$Perl_count = $array[3];
$Cobol_count = $array[4];
$Fortran_count = $array[5];
print "$C_count"; <<<< here i just want to see if i can get
reply with the correct no put it is wrong
if ($lang == "C"
{
$C_count =$array[0]+1;
}
else
{
$C_count =$array[0];
}
if ($lang == "Java"
{
$Java_count =$array[1]+1;
}
else
{
$Java_count =$array[1];
}
if ($lang == "Ada"
{
$Ada_count =$array[2]+1;
}
else
{
$Ada_count =$array[2];
}
if ($lang == "Perl"
{
$Perl_count =$array[3]+1;
}
else
{
$Perl_count =$array[3];
}
if ($lang == "Cobol"
{
$Cobol_count =$array[4]+1;
}
else
{
$Cobol_count =$array[4];
}
if ($lang == "Fortran"
{
$Fortran_count =$array[5]+1;
}
else
{
$Fortran_count =$array[5];
}
flock (PL,8);
close (PL);
# reopen and write to the file --
open(PL,">plsurv.dat"
flock(PL,2);
print PL "$C_count $Java_count $Ada_count $Perl_count $Cobol_count $Fortran_count";
flock(PL,8);
close (PL);
print "$C_count"; <<<here too wrong response
print "<h3>";
print "Thanks $firstn , for your input !";
print "</h3>";
print br;print br;
print "</h2>";
print "here is the votes";
print "</h2>";
print br;
print " C/C++ : $C_count" ;
print br;
print " Java : $Java_count" ;
print br;
print " Ada : $Ada_count" ;
print br;
print " Perl : $Perl_count" ;
print br;
print " Cobol : $Cobol_count" ;
print br;
print " Fortran : $Fortran_count" ;
print end_html;