This script was supposed to be just a simple database script, something went terribly wrong. The line: use CGI::Carp qw(fatalsToBrowser); prints this error message:
syntax error at playerpost.cgi line 56, near ") {" syntax error at playerpost.cgi line 75, near "}" Execution of playerpost.cgi aborted due to compilation errors.
These line are: 1. if (($gender eq "") || ($age eq "") || ($county eq "") || ($bracket eq "") || ($position eq "") || ($name eq "") || ($email eq "") || ($experience eq "")) { and 2. elsif ($email =~ m/\w{1,}\@\w{1,}\.\w{1,}/) { I've gone over the script millions of times, but I can't find anything wrong! Please help! :-) This is the entire script:
#!/usr/bin/perl print "Content-type: text/html\n\n"; use CGI::Carp qw(fatalsToBrowser); read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($key, $value) = split(/=/, $pair); $key =~ tr/+/ /; $key =~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~s/<!--(.|\n)*-->//g; if ($formdata{$key}) { $formdata{$key} .= ", $value"; } else { $formdata{$key} = $value; } } $gender = $formdata{'gender'}; $age = $formdata{'age'}; $county = $formdata{'county'}; $bracket = $formdata{'bracket'}; $position = $formdata{'position'}; $name = $formdata{'name'}; $email = $formdata{'email'}; $experience = $formdata{'experience'}; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); $month = $mon+1; $year1 = $year+1900; $date = "$mday\/$month\/$year1" if (($gender eq "") || ($age eq "") || ($county eq "") || ($bracket eq + "") || ($position eq "") || ($name eq "") || ($email eq "") || ($exp +erience eq "")) { print <<"PrintTag"; <html><head><title>Insufficient information</title><style> A:hover {color: "#CB5C03"; text-decoration: underline; font-family: "P +egasus"} A:link {color: "black"; font-family: "Pegasus"; text-decoration: none} A:visited {color: "#CB5C03"; text-decoration: none; font-family: "Pega +sus"} P {font-family: "Pegasus"; color:black} H1 {font-family: "Pegasus"; color:black} H3 {font-family: "Pegasus"; color:black} H2 {font-family: "Pegasus"; color:black} </style></head><body bgcolor = "#08BD29" text="black"> <BASE HREF="http://soccermb.netfirms.com/"> <img src="sidebar21.gif" align="left" width="20" height="300"><img src +="sidebar21.gif" align="right" width="20" height="300"><center><h2>In +sufficient information</h2></center> <center><h3>Please click the 'Back' button on your browser to try agai +n</h3></center> PrintTag exit; } elsif ($email =~ m/\w{1,}\@\w{1,}\.\w{1,}/) { elsif ($name =~ m/\w{3}/) { open(DATA, ">>$ENV{'DOCUMENT_ROOT'}/cgi-bin/datap.txt") || &error; flock(DATA, 2); print DATA "$gender\+$age\+$county\+$bracket\+$position\+$name\+$date\ ++$experience\+$email\n"; flock(DATA, 8); close(DATA); } else { print <<"PrintTag"; <html><head><title>Incorrect information</title><style> A:hover {color: "#CB5C03"; text-decoration: underline; font-family: "P +egasus"} A:link {color: "black"; font-family: "Pegasus"; text-decoration: none} A:visited {color: "#CB5C03"; text-decoration: none; font-family: "Pega +sus"} P {font-family: "Pegasus"; color:black} H1 {font-family: "Pegasus"; color:black} H3 {font-family: "Pegasus"; color:black} H2 {font-family: "Pegasus"; color:black} </style></head><body bgcolor = "#08BD29" text="black"> <BASE HREF="http://soccermb.netfirms.com/"> <img src="sidebar21.gif" align="left" width="20" height="300"><img src +="sidebar21.gif" align="right" width="20" height="300"><center><h2>In +correct information</h2></center> <center><h3>You must type three initials. Please click the 'Back' but +ton on your browser to try again</h3></center> PrintTag exit; } } else { print <<"PrintTag"; <html><head><title>Incorrect information</title><style> A:hover {color: "#CB5C03"; text-decoration: underline; font-family: "P +egasus"} A:link {color: "black"; font-family: "Pegasus"; text-decoration: none} A:visited {color: "#CB5C03"; text-decoration: none; font-family: "Pega +sus"} P {font-family: "Pegasus"; color:black} H1 {font-family: "Pegasus"; color:black} H3 {font-family: "Pegasus"; color:black} H2 {font-family: "Pegasus"; color:black} </style></head><body bgcolor = "#08BD29" text="black"> <BASE HREF="http://soccermb.netfirms.com/"> <img src="sidebar21.gif" align="left" width="20" height="300"><img src +="sidebar21.gif" align="right" width="20" height="300"><center><h2>In +correct information</h2></center> <center><h3>You must type your email address in the form 'email@addres +s.com'.<br>Please click the 'Back' button on your browser to try agai +n</h3></center> PrintTag exit; } sub error { print "Content-type: text/html\n\n"; print "<center>Can't open file</center>"; exit; }

In reply to Faulty Script by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.