Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

I use CGI.pm for

by vroom (His Eminence)
on Jun 07, 2000 at 23:38 UTC ( [id://16940]=poll: print w/replies, xml ) Need Help??

Vote on this poll

Only Form tag generation and handling
[bar] 24/10%
FORM+HTML tag generation
[bar] 67/28%
Param Handling only
[bar] 79/33%
Never used it
[bar] 68/29%
238 total votes
Replies are listed 'Best First'.
RE: I use CGI.pm for
by royalanjr (Chaplain) on Jun 08, 2000 at 00:05 UTC

    Call me crazy, but I generally do not let CGI.pm do my HTML. I prefer to write that out myself. Being new, I know I have not explored all its possibilies yet though. I do use it to pass my parameters around.

    Roy Alan

    "I quit; I concede. Tanj on your silly game!" -- Louis Wu
      Ok, you're crazy. :)

      I guess I'm worse cause I still use the "cgi-lib.pl compatility mode" with ReadParse(*in); Now is that lame or what?

      #!/home/bbq/bin/perl
      # Trust no1!
      Thus saith royalanjr:
      Call me crazy, but I generally do not let CGI.pm do my HTML. I prefer to write that out myself. Being new, I know I have not explored all its possibilies yet though. I do use it to pass my parameters around.
      Once you discover the sticky fields technology of web form generation, you'll never go back. CGI.pm rules!

      -- Randal L. Schwartz, Perl hacker

        Not to mention, with some creative map use, you can create dynamic tables and such pretty easy, while not breaking the stylish print 'some','things','in','a','row'; :-)
        use CGI;
        my $cgi = CGI->new;
        print $cgi->header,
              $cgi->start_html('Times Tables'),
              $cgi->table( { -border => 1 },
                         ( map {
                          my $r = $_;
                          $cgi->Tr( ( map {
                                   $cgi->td( $_ * $r ),
                                  } 1 .. 50 ) ),
                         } 1..50 ) ),
              $cgi->end_html;
        
        And for the obfuscated lovers in all of us (some people would call the above obfuscated.. slackers:-)
        use CGI;my$cgi=CGI->new;print##
        $cgi->header=>$cgi->start_html#
        ('Times Tables')=>$cgi->table(#
        {-border=>1}=>(map{my$r=$_;$cgi
        ->Tr((map{$cgi->td($_*$r)}1..50
        ))=>}1..50))=>$cgi->end_html;##
        
        --
        Casey
        
        I've run into a case where CGI.pm was a little too sticky. Still, it's really a good way to go, as you don't have to worry about updating code in a script somewhere when the HTML specification changes.

        Has anyone tried the 3.0 alpha versions? They're supposed to be much smaller and much, much faster.

        Sticky Fields?!?

        *pulling at my hair in despair, dropping to my knees*

        So much to learn!!!

        Roy Alan

        "I quit; I concede. Tanj on your silly game!" -- Louis Wu

      Try it you'll like it. I certainly do. It takes a little bit to get used to but the shortcuts for creating multiple table rows and table data are invaluable. I certainly don't know all it can do but the little that I do know sure seems to go a long ways. It is also easy to switch from using CGI.pm notation for HTML to simple here documents, if I want to write out HTML by hand.
        Personally, I use a mix of it, pending on what i shall do and who i am writing it for. Sometimes I find it easier to use the HTML tags rather than the shortcuts, especially when i make complicated tables.
        And there's always the option of a external HTML file and use regexps to insert variables:
        open(HTML, "<a_file.html") or die "cant open HTML file: $!\n"; while($row = <HTML>) { $row =~ s/---(.*?)---/eval $1/eg; print $row; } close HTML;
        Which will look for ---$variablename--- in the HTML code and replace it with the variable (as if you didnt know ; )) I also use HTML comment flags to insert more complicated structures. I've written a rather simple Web-based discussion forum using this technique, which allows the administrator of the site to change the design without knowing any Perl at all.
RE: I use CGI.pm for
by JanneVee (Friar) on Jun 08, 2000 at 00:48 UTC
    Hmm.. I actually never use CGI.pm to generate my form tags. But handle them. I also use CGI.pm for header generation. (Cookies and expirydates and such!)

      I use it to generate some of my html and handle the parameters. I prefer to do my own HTML outside of the <head> tags though. hidden() makes things easier occasionally, and I do use that.

      CGI.pm header generation is very nice, though.

      I use it to generate some of my html and handle the parameters. I prefer to do my own HTML outside of the <head> tags though. hidden() makes things easier occasionally, and I do use that. CGI.pm header generation is very nice, though.
RE: I use CGI.pm for
by buzzcutbuddha (Chaplain) on Jun 08, 2000 at 16:13 UTC
    Working at a web design company, I have always strived to keep the design and the code
    seperate, especially because you often have clients who want to change the design of their
    page often.
    The other consideration is that HTML recently changed to XHTML, a subset of XML, and I haven't
    heard anything stating that cgi.pm is up to date with the new standard yet.

    If you want to know more about XHTML, I suggest you check out:
    • W3C's Explanation of XHTML
    • Mozquito.org which has already created the first IDE for XHTML.
      Sebastian Schnitzenbaumer and Cassandra Greer worked with other authors to produce
      Wrox's first book on XHTML.
    cheers!
      Thus spoke buzzcutbuddha:
      The other consideration is that HTML recently changed to XHTML, a subset of XML,
      That's a bit like saying "a good novel is a subset of the dictionary words". I suppose it's literally true, but it's more accurate to say something like "XHTML is an XML application". You'll have to limit yourself to a subset of XHTML if you want backward compatibility with older browsers, but as far as XHTML is concerned, it is XML with a specific DTD.

      -- Randal L. Schwartz, Perl hacker

      XHTML, is nice... but the <br /> (br with a space then the empty element delineating slash) thing seems like a bit of a hack which is neither XML nor HTML... then again, I have only fooled with XML and never really made a full app with it. And who know which if any browsers would barf at such a syntax. Mad love to the everything engine, though.

      On the topic of the poll, I must be honest and say I've used CGI.pm to generate entire pages, just do forms, and parse form variables from forms I wrote by hand. The other day in irc, chromatic gave me the tip of HTML::Template which really helps things out when trying to separate formatting (HTML) from code. I highly recommend it. It shortened my latest job by at least 100 lines.

        Actually, since I have started learning XHTML, I have used the <br /> as in my post here, and I have
        yet to see a browser complain or improperly render the layout. And as far as I remember, XML does use the
        space and closing slash on empty elements. I don't know how far XHTML will be accepted in it's current
        incarnation, but we'll see. I guess the biggest reason I don't use cgi.pm for the actual layout is because
        you can't specify with DTD you want to use. I guess that's possible with HTML::Template? I need to read more
        on that.
RE: I use CGI.pm for
by perlcgi (Hermit) on Jun 14, 2000 at 21:06 UTC
    MY CONFESSION

    Bless me brothers for I have sinned...
    I used Frontpage Express 6 times to create HTML. I just embedded my variables in the html, and spat it out as a HERE doc.
    Brothers... I also told the following lie:
     meta name=Generator content=mycgi.pl
    It felt quite good.

RE: I use CGI.pm for
by Punto (Scribe) on Jun 08, 2000 at 07:42 UTC
    I didn't know cgi.pm could be used to generate html and form tags. Where can I find a simple, easy and nice tutorial for that? :-)
      Here's the official cgi.pm site.
      There's also a book which i can recommend, The official guide to programming cgi.pm. written by L. Stein who wrote the module. You can obtain info about it at the page or at Wiley.

      /wonko

RE: I use CGI.pm for
by RichardH (Sexton) on Jun 14, 2000 at 17:21 UTC
    Very rarely do we use CGI.pm to generate HTML at the site I work at. We try to seperate all the interface design out of the programming logic. We have 2 html programmers and 3 perl programmers, and we leave as much of the html as possible to the html programmers. We try to avoid situations where they have to directly access our perl code. This makes updates and debugging much easier for both groups. Of course, there are times when embedding html inside perl is simply easier and faster, but that seems to be the exception, not the rule.
RE: I use CGI.pm for
by anmaco (Novice) on Jun 10, 2000 at 01:12 UTC
    Excuse me wise monks - but what is different about CGI in the afternoon? OK Ok I'm joking, please don't give me a bad vote - but what is CGI.pm?
      CGI.PM is a module which makes your life much easier if you are dealing with CGI scripts. It is a part of the standard Perl distribution. See my post above for the link to the official cgi.pm page, and you will find out why so many use it ;)
      /Wonko

      See the above posts for a link to the CGI.pm

      "pm" stands for "perl module" not "post meridiem" :)

        I thought it stood for "pre-menstrual".........
        "all was created from /dev/null and shall return to /dev/null"

View List Of Past Polls


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-03-19 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found