Forum Moderators: coopster & phranque

Message Too Old, No Replies

More perl help (basic stuff)

         

tester121

4:01 am on Feb 7, 2006 (gmt 0)

10+ Year Member



I keep having problems with creating scripts then running them & they seem fine then later they don't work?! I'm not sure what I'm doing, I don't change permissions or the file or redirect the page or anything. Here's a simple example of one I did & it worked fine when I tried it then I had someone else check it out & it gave a blank page. Not sure where I'm going wrong. I've looked it over & it seems fine, any help is greatly appreciated. I'm sure I'm missing something somewhere!

#!/usr/bin/perl
#simple.cgi - Create a simple query

use CGI;
$query =CGI->new;

$Name=$query->param('Username');
$Age=$query->param('Age');
$Birth=$query->param('Birth');

print $query->header();

#validate input data
if ($Name eq "" or $Age eq "" or $Birth eq "") {
display_error_page();
}
else {
display_acknowledgment();
}

# ******user defined function*****
sub display_error_page {
print "<html>\n";
print "<head><title>Errors on Page</title></head>\n";
print "<body>\n";
print "<h2>Click on your brower's back button,\n";
print "to complete the entire form</h2>\n";
print "</body></html>\n";
} #end display_error_page

sub display_acknowledgement {
print "You said your name is: $Name\n";
print "<br>";
print "You said your age is: $Age\n";
print "<br>";
print "Your city of birth is: $Birth\n";

} #end display_acknowledgment

perl_diver

6:08 am on Feb 7, 2006 (gmt 0)

10+ Year Member



well, you do have to spell your sub routines correctly for them to work:

display_acknowledgment();
sub display_acknowledgement {

you are missing an "e" after the letter "g" when you call the sub routine. A lesson in using shorter names maybe? :)

tester121

11:44 am on Feb 7, 2006 (gmt 0)

10+ Year Member



That was it! 8}