CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Calling Subroutines

 



d1zz13
User

Aug 29, 2000, 11:36 PM

Post #1 of 2 (510 views)
Calling Subroutines Can't Post

Good Morning all,

I wonder if anyone out there could help? I've created a script that prints an html form, then when I want to parse the form I call a subroutine, but it just doesn't appear to work.

I've added some very simple code here to display what I've got, is it difficult or am I missing something simple?

Here's the code, and you can see it in action here.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


#!/usr/bin/perl

# Call subroutine print_html
&print_html;

# Specifies the subroutine print_html
sub print_html{
print "Content-type: text/html\n\n";
print qq{
<html>
<head>
<title>Test Form Script</title>
</head>
<body bgcolor="#000000" text="#FFFFFF">
<form method="post" action="?get_info">
Select an option<br>
<input type="radio" name="select" value="Yes">
<input type="radio" name="select" value="No"><br>
<input type="Submit" name="Submit" value="Submit">
</form>
</body>
</html>
}
}

# Specifies the subroutine get_info
sub get_info{
use CGI;
$form=newCGI;
$results=$form->param('select');
&check_it;
}

# Specifies the subroutine check_it
sub check_it{
print "Content-type: text/html\n\n";
print "You selected $results";
}
</pre><HR></BLOCKQUOTE>

Regards and TIA
Richard Smile

------------------
Dizzie Scripts


perlkid
stranger

Aug 31, 2000, 9:58 PM

Post #2 of 2 (510 views)
Re: Calling Subroutines [In reply to] Can't Post

 
I think that your sub{ is getting confused with the { in print qq{

so instead of

print qq{
<html>
}
try

print qq~
<html>
~;

Also I noticed that you left out the ; after the } wich is part of the print qq{}

You need to end the qq{} with a ; always. I think That may contibute to the confusion between the sub's } and the print qq's }.

But Try the

print qq~
<html>
~;

Anyway and stay away from print qq{}

Perlkid

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives