I have created the following program. In which I create new information in the program and read some data and then write to another file. However, it give me the following error:
String found where operator expected at cardp.cgi line 38, near "OUTF "$countp2|"" (Do you need to predeclare OUTF?) syntax error at cardp.cgi line 38, near "print" Execution of cardp.cgi aborted due to compilation errors. could not fire up cardp.cgi
#!/usr/bin/perl
print "Content-type:text/html\n\n";
#cardp.cgi - use with card.html and card.cgi and cardp.out - Apartment for Rent
open(INF,"cardp.out" or dienice("Couldn't open apart.out for reading: $! \n"
@data = INF
print "<h2>Card Payment</h2>\n";
# First we initialize some counters and hashes for storing the
# summarized data.
$countp2 =0;
$commentary ="";
&print_page_start;
$card = $query->param('card');
$number = $query->param('number');
$date = $query->param('date');
$namec = $query->param('namec');
open(OUTF, "<cardc.out" or dienice("Couldn't open auto.out for reading: $! \n"
foreach $i (@data) {
chomp($i);
($name,$address,$city,$state,$zipcode,$location,$photo,$squarefoot,$nofbedroom,
$nofbathroom,$livingroom,$familyroom,$dinningroom,$basement,$deck,
$fireplace,$petallowed,$utility,$askingprice,$security,$deposit,$email,$telephone,$timetocall,$comment1,
$costt,$costp,$pay,$month,$day,$year) = split(/\|/,$i);
# this is the same as $countp2 = $countp2 + 1;
# Reset the file pointer to the end of the file, in case
# someone wrote to it while we waited for the lock...
print OUTF "$FORM {'telephone'}|";
print OUTF "$FORM{'card'}|";
print OUTF "$FORM{'number'}|";
print OUTF "$FORM{'date'}|";
print OUTF "$FORM{'namec'}|";
print OUTF "$FORM{'address'}|";
print OUTF "$FORM{'city'}|";
print OUTF "$FROM{'state'}|";
print OUTF "$FORM{'zipcode'}\n"
}
close (OUTF);
close (INF);
sub print_page_start {
print $query->header;
print "<html>\n<head>\n<TITLE>Credit Card Information</TITLE>\n";
print "</HEAD>\n<BODY>\n";
print "<FORM>\n";
print "Name of the card<input type=\"radio\" name=\"card\" value=\"Visa\">Visa<input type=\"radio\" name=\"card\" value= \"MasterCard\">Master Card<input type=\"radio\" name=\"card\" value=\"Discover\">Discover\n<br>";
print "Card Number<input type=\"text\" name=\"number\">Number</A>\n<br>";
print "Expiration Date<input type=\"text\" name=\"date\">date\n<br>";
print "Your Name as it appears on the card <input type=\"text\" name=\"namec\">Name\n<br>";
print "<INPUT TYPE=\"submit\"><INPUT Type=\"reset\">\n<br>";
print "<FORM>\n";
}
print <<EndHTML;
EndHTML
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
I would appreciate any help that you can provide.
String found where operator expected at cardp.cgi line 38, near "OUTF "$countp2|"" (Do you need to predeclare OUTF?) syntax error at cardp.cgi line 38, near "print" Execution of cardp.cgi aborted due to compilation errors. could not fire up cardp.cgi
#!/usr/bin/perl
print "Content-type:text/html\n\n";
#cardp.cgi - use with card.html and card.cgi and cardp.out - Apartment for Rent
open(INF,"cardp.out" or dienice("Couldn't open apart.out for reading: $! \n"
@data = INF
print "<h2>Card Payment</h2>\n";
# First we initialize some counters and hashes for storing the
# summarized data.
$countp2 =0;
$commentary ="";
&print_page_start;
$card = $query->param('card');
$number = $query->param('number');
$date = $query->param('date');
$namec = $query->param('namec');
open(OUTF, "<cardc.out" or dienice("Couldn't open auto.out for reading: $! \n"
foreach $i (@data) {
chomp($i);
($name,$address,$city,$state,$zipcode,$location,$photo,$squarefoot,$nofbedroom,
$nofbathroom,$livingroom,$familyroom,$dinningroom,$basement,$deck,
$fireplace,$petallowed,$utility,$askingprice,$security,$deposit,$email,$telephone,$timetocall,$comment1,
$costt,$costp,$pay,$month,$day,$year) = split(/\|/,$i);
# this is the same as $countp2 = $countp2 + 1;
# Reset the file pointer to the end of the file, in case
# someone wrote to it while we waited for the lock...
print OUTF "$FORM {'telephone'}|";
print OUTF "$FORM{'card'}|";
print OUTF "$FORM{'number'}|";
print OUTF "$FORM{'date'}|";
print OUTF "$FORM{'namec'}|";
print OUTF "$FORM{'address'}|";
print OUTF "$FORM{'city'}|";
print OUTF "$FROM{'state'}|";
print OUTF "$FORM{'zipcode'}\n"
}
close (OUTF);
close (INF);
sub print_page_start {
print $query->header;
print "<html>\n<head>\n<TITLE>Credit Card Information</TITLE>\n";
print "</HEAD>\n<BODY>\n";
print "<FORM>\n";
print "Name of the card<input type=\"radio\" name=\"card\" value=\"Visa\">Visa<input type=\"radio\" name=\"card\" value= \"MasterCard\">Master Card<input type=\"radio\" name=\"card\" value=\"Discover\">Discover\n<br>";
print "Card Number<input type=\"text\" name=\"number\">Number</A>\n<br>";
print "Expiration Date<input type=\"text\" name=\"date\">date\n<br>";
print "Your Name as it appears on the card <input type=\"text\" name=\"namec\">Name\n<br>";
print "<INPUT TYPE=\"submit\"><INPUT Type=\"reset\">\n<br>";
print "<FORM>\n";
}
print <<EndHTML;
EndHTML
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
I would appreciate any help that you can provide.