Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

CGI.PM related questions.

by Apterigo (Scribe)
on Jun 13, 2000 at 02:57 UTC ( [id://17805]=perlquestion: print w/replies, xml ) Need Help??

Apterigo has asked for the wisdom of the Perl Monks concerning the following question:

I just have a few basic questions about CGI. say I have a script that is like this:
#!/usr/bin/perl print "Content-type: text/html\n\n"; print "<HTML><HEAD><TITLE>Title Page</TITLE></HEAD>\n"; print "<CENTER><FONT SIZE=+7>Some text here</FONT></CENTER></HTML>\n";
now, I want to use CGI.pm, so I say;
!#/usr/bin/perl use CGI; $q = new CGI; print $q->header; print $q->start_html("Title Page");
now, if all the above is correct, how do I convert the CENTER and FONT tags?

Replies are listed 'Best First'.
(jcwren) Re: CGI.PM related questions.
by jcwren (Prior) on Jun 13, 2000 at 03:08 UTC
    Somthing like this:
    use strict; use CGI; { my $p = new CGI; print $p->header; print $p->start_html ("Title Page"); print $p->p (center ($p->font ({-size=>'+7'}, "This is a test" +))); print $p->end_html; }
    would give you this:
    Content-Type: text/html <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <HTML> <HEAD> <TITLE>Title Page</TITLE> </HEAD> <BODY> <P><CENTER><FONT SIZE="+7">This is a test</FONT></CENTER></P> </BODY> </HTML>
    (I reformatted the HTML to make it more readable. CGI.pm usually runs stuff together)

    It takes a little reading, but 'perldoc CGI' has some pretty good information. There's an excellent tutorial written by Lincoln Stein, that someone has a link to, but I don't know where it is. Anyone?

    --Chris
      jcwren said something like:
      I reformatted the HTML to make it more readable.
      Have you seen CGI::Pretty? Just say use CGI::Pretty blah blah in place of use CGI blah blah. You get newlines and indented output. Cool.

      -- Randal L. Schwartz, Perl hacker

        Per the amazing Randal L. Schwartz, change the lineuse CGI;touse CGI::Pretty qw (:all);and you'll get pretty printing.

        CGI::Pretty is located here, via the CPAN search.

        --Chris
      The recommended test CGI script generates the following error: Status: 302 Found Location: http://cgi2.tripod.com/bin/error?error=Your%20script%20produced%20this%20error%3A%20Unable%20to%20create%20sub%20named%20%22%2AMember%3A%3Acenter%22%20at%20.%2Fhello.pl%20line%2022.%0A URI: http://cgi2.tripod.com/bin/error?error=Your%20script%20produced%20this%20error%3A%20Unable%20to%20create%20sub%20named%20%22%2AMember%3A%3Acenter%22%20at%20.%2Fhello.pl%20line%2022.%0A Content-type: text/html Can anyone tell me what the problem is?
      The recommended test CGI script generates the following error: Status: 302 Found Location: http://cgi2.tripod.com/bin/error?error=Your%20script%20produced%20this%20error%3A%20Unable%20to%20create%20sub%20named%20%22%2AMember%3A%3Acenter%22%20at%20.%2Fhello.pl%20line%2022.%0A URI: http://cgi2.tripod.com/bin/error?error=Your%20script%20produced%20this%20error%3A%20Unable%20to%20create%20sub%20named%20%22%2AMember%3A%3Acenter%22%20at%20.%2Fhello.pl%20line%2022.%0A Content-type: text/html Can anyone tell me what the problem is?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-26 01:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found