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

Re^3: CGI program

by Marshall (Canon)
on Sep 23, 2009 at 16:24 UTC ( [id://797021]=note: print w/replies, xml ) Need Help??


in reply to Re^2: CGI program
in thread CGI program

You can write CGI programs in lots of different languages. Here is a simple one in Perl. If you run this code, it will output HTML. If you save that HTML to a file, you can display that file contents in a browser (use open | file).

#!/usr/bin/perl -w use strict; use CGI; my $q = new CGI; my $timestamp = localtime; print $q->header ("text/html"), $q->start_html ( -title => "Current Time"), $q->h2 ("Current Time"), $q->hr, $q->p( "This system figures current time as: ", $q->b($timestamp) ), $q->end_html;
You can call this short thing, say "time". Have your friendly (I hope) web administrator set this up so that it can be accessed via a URL and bingo you have your first CGI program working! Basically to output a web page, write a program that spews out HTML to stdout. There is some config stuff at the server end, but this is the idea of what your program has to do.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2025-12-13 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (93 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.