Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: print content in cgi and html

by LAI (Hermit)
on Sep 26, 2003 at 12:49 UTC ( [id://294394]=note: print w/replies, xml ) Need Help??


in reply to print content in cgi and html

The Best way to do what you're trying to would be to look into the CGI module from CPAN. There are all sorts of nifty subs in that module that make any CGIer's life way easier. For instance (from the docs), here's a "Hello World" page done with the functions from CGI.pm:

#!/usr/local/bin/perl use CGI qw/:standard/; # load standard CGI routines print header, # create the HTTP header start_html('hello world'), # start the HTML h1('hello world'), # level 1 header end_html; # end the HTML

And the icing on the cake is that CGI should be already installed in your existing distribution of Perl!

LAI

__END__

Replies are listed 'Best First'.
Re: Re: print content in cgi and html
by tilly (Archbishop) on Sep 27, 2003 at 23:03 UTC
    I personally find that using CGI's named subroutines almost always is the wrong way to factor code for all but very short CGI scripts for personal use.

    Just because someone respected found a piece of code worth writing does not mean that you should be using it whenever you can.

    For some generalities on the design factors that go into choosing how to integrate HTML and your Perl code together, you can read Re (tilly) 6: Code Critique. For lots more on why templating is generally a better solution when you have a large problem, see Building and Managing Web Sites with the Template Toolkit. Before choosing the templating system for you, I strongly suggest reading perrin's Choosing a Templating System.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://294394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found