Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Prototype not terminated"

Status
Not open for further replies.

yitzle

Programmer
Sep 10, 2006
8
CA
My script reads:

#!/local/bin/perl
print "ds";
sub writeLog (
print "dsaf";
}

and I get an error. Why? Please?
 
You have a typo. Change the parenthesis "(" to a bracket "{". From:

Code:
sub writeLog [COLOR=red]([/color]

to

Code:
sub writeLog [COLOR=green]{[/color]

perl gives the error that it does because using a parenthesis after a subroutine definition is the way to write a prototype. I doubt that is what you want in this case. So simply fix the typo, and perl will be happy again. :)
 
* yitzle pulls out a handgun and blasts out his brains *

Why can't Perl use brackets that have higher visibility?

Lemme see if I can get it running now.

Thanks!
 
That's what you get for working on a saturday.

If all else fails, trust the error reporting and the line numbers. True, they are sometimes not completely accurate in their description. But they should be more than enough info to at least track it down. And in this case "Prototype not terminated at error.pl line 3.", kinda says it plenty =)
 
I suppose. Assuming you got the error before.
I'm sorta new to Perl.
Thanks for the help.
I now have a working online voting system :)
If you wanna see it, its uncommented:

But I tested it. It uses a form like:
It checks if you are on the voting list, if you voted. It adds your vote.
Its neat ;)

Thanks!!
 
Just as a quick piece of advice, I would clean up the following code.

voting.cgi said:
sub printNoMember {
print "
<HTML>\n
<HEAD>\n
<TITLE>Voting System By Isaac Good</TITLE>\n
</HEAD>\n
<BODY>\n
You are not on our records.<BR>\n
If you think you ought to be, please contact the administrative at jesa\@skule.ca.<BR>\n
Click <A HREF=$urlhome>here</A> to go to the JESA homepage.<BR>\n
</BODY>\n
</HTML>\n
";
}

For one, you could remove all the explicit return characters, as they are needlessly doubling your spacing. Secondly, I would use <<END to indicate your output. Using double quotes has the annoying habit of forcing you to escape quotes in your print statement. Alternative, the qq{} method of quote is a very good method as well.

Code:
sub printNoMember {
	print <<END;
<HTML>
<HEAD>
<TITLE>Voting System By Isaac Good</TITLE>
</HEAD>
<BODY>
You are not on our records.<BR>
If you think you ought to be, please contact the administrative at jesa\@skule.ca.<BR>
Click <A HREF=$urlhome>here</A> to go to the JESA homepage.<BR>
</BODY>
</HTML>
END;
}
 
Thanks for the feedback!
I realized after viewing the output that the \n is useless.
My code should have qq~ ... ~;
I guess I forgot to update the file ;)
Fixing.
I temp switched to " becuase of the error. I Googled the error and I thought I had an unmatched " or something...
The end is cool. I used it in Linux before. Didn't know I could stick it in Perl.
Apparently I did have " in my code... Odd.
Fixed now.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top