StarRice has asked for the wisdom of the Perl Monks concerning the following question:
I would like someone to look over my .cgi script. Its not very long, and is for a class. I completed it and am not looking for answers, however it's not working, and I don't understand the errors i'm getting.
#!/usr/bin/perl #c11case2a.cgi - Allows user to enter info use CGI qw(:standard -debug); #print “Content-type: text/HTML\n\n”; #prevent Perl from creating undeclared variables use strict; #declare variables and assign variables my ($item, $C_basket, @basket); #make cookies $C_basket = cookie( -name => "Basket", -value => "@basket", -path =>"../../cgi-bin/chap11"); #send cookies print header(-cookie => $C_basket ); #display Web page Print <<addressForm; <HTML> <HEAD><TITLE>Jarrod Accessories</TITLE></HEAD> <BODY> <H2>Jarrod Accessories</H2> <H3>Enter Your Information</H3><HR> <FORM ACTION="http://endor.vvc.edu/~shaninarice/cgi-bin/chap11/c11case +2b.cgi" METHOD=POST> <TABLE> <TR><TD>Name</TD><TD><INPUT NAME=Name SIZE=40></TD></TR> <TR><TD>Address</TD><TD><INPUT NAME=Address SIZE=40></TD></TR> <TR><TD>City</TD><TD><INPUT NAME=City SIZE=40></TD></TR> <TR><TD>State</TD><TD><INPUT NAME=State SIZE=40></TD></TR> <TR><TD>Zip Code</TD><TD><INPUT NAME=Zipcode SIZE=40></TD></TR> </TABLE> <BP><INPUT TYPE=submit VALUE=Submit> <INPUT TYPE=reset></P> </FORM> </BODY> </HTML> addressForm
And the errors I get running perl -c:
and the second one....Bareword found where operator expected at c11case2a.cgi line 29, near + "<TITLE>Jarrod" (Missing operator before Jarrod?) Bareword found where operator expected at c11case2a.cgi line 32, near +"<H3>Enter" (Missing operator before Enter?) String found where operator expected at c11case2a.cgi line 33, at end +of line (Missing semicolon on previous line?) syntax error at c11case2a.cgi line 29, near "HEAD>" Can't find string terminator '"' anywhere before EOF at c11case2a.cgi +line 33.
#!/usr/bin/perl #c11case2b.cgi - Displays user info print “Content-type: text/HTML\n\n”; use CGI qw(:standard); #prevent Perl from creating undeclared variables use strict; #declare and assign variables my ($name, $address, $city, $state, $zipcode, $item, $rec, @items); my @purchases = ( “Gold Bracelet”, “Silver Bracelet”, “Diamond Necklace”, “Ruby Earrings”, “Pearl Ring”); $name = param(‘Name’); $address =param(‘Address’); $city =param(‘City’); $state =param(‘State’); $zipcode =param(‘Zipcode’); #get order from cookie @items = split (/ /, cookie (‘Basket’)); #display order confirmation print "<HTML>\n"; print "<HEAD><TITLE>Jarrod Accessories</TITLE></HEAD>\n"; print "<BODY>\n"; print "<H1H2>Jarrod Accesories</H1H2> \n"; print “$name, Thank you for your order of:<BR><BR>\n”; foreach $item (@items) { print “$purchases [$item]<BR>\n”; } print “<BR>It will be shipped to: <BR><BR>\n”; print “$address<BR>\n”; print “$city,$nbsp; $state $nbsp; $zipcode<BR>\n”; print "</BODY>\n”; print “</HTML>\n";
And It's errors:
Bareword found where operator expected at c11case2b.cgi line 10, near + "my @purchases = ( "Gold" (Might be a runaway multi-line "" string starting on line 3) (Do you need to predeclare my?) syntax error at c11case2b.cgi line 10, near "my @purchases = ( "Gold B +racelet" Unrecognized character \xE2; marked by <-- HERE after d Bracelet<-- HE +RE near column 33 at c11case2b.cgi line 10.
|
|---|