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: Re: [kate212] Perl and Html: Edit Log



Zhris
Enthusiast

Sep 2, 2013, 8:21 AM


Views: 2532
Re: [kate212] Perl and Html

Hi,

The following is a basic CGI script with embedded HTML. I have highlighted key elements in red:


Code
#!/usr/bin/perl 
use strict;
use warnings;
use CGI;

# create new CGI object.
my $cgi = CGI->new( );

# assign value of mybutton "Press" to variable $mybutton.
my $mybutton = $cgi->param('mybutton');

# test if button has been pressed / assign a response message to variable $mybuttonresponse.
my $mybuttonresponse = ( $mybutton ) ? 'button pressed' : 'button not pressed' ;

# print appropriate content type.
print $cgi->header( );

# print HTML.
print <<"HTMLcode";
<html>
<head>

</head>
<body>
<p>$mybuttonresponse</p>
<form action="name.pl" method="post">
Please click here: <input type="submit" name="mybutton" value="Press">
</form>
</body>
</html>
HTMLcode

exit;


Chris


(This post was edited by Zhris on Sep 2, 2013, 8:21 AM)


Edit Log:
Post edited by Zhris (Enthusiast) on Sep 2, 2013, 8:21 AM


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

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