View previous topic :: View next topic |
Author |
Message |
neko n00b
Joined: 14 May 2002 Posts: 9 Location: UCSD
|
Posted: Tue Sep 17, 2002 4:13 pm Post subject: html output in Perl? |
|
|
I code perl at work, and have recently been asked to convert some of my scripts to include a web interface/output...(These scripts generate statistics on network outages/utilization/etc) I've been using CGI.pm but haven't been too happy with it other than the parameter parsing (seems to be quirky with forms and such at times) and was wondering what people typically use for html output? Is doing it by hand really the best solution? or are there other modules I don't know about...
Any suggestions are much appreciated
-Neko |
|
Back to top |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Tue Sep 17, 2002 6:05 pm Post subject: |
|
|
I use CGI.pm, and love it. What problems have you been having with it? It allows me to say things like: Code: | print
$cgi->header( -type => 'text/html', -charset => 'x-euc-jp' ),
$cgi->start_html( -title => "" ),
$cgi->h1( "Estrance $uid" ),
$cgi->start_form( -action => 'chu.cgi', -method => 'GET' ),
$cgi->hidden( -name => 'uid', -value => $uid ),
$cgi->start_table( -border => 0, -cellpadding => 6 ),
$cgi->Tr( $cgi->th( {-align => left}, '' ),
$cgi->td( $uid ) ),
$cgi->Tr( $cgi->th( {-align => left}, '' ),
$cgi->td( $cgi->textfield( -name => 'name',
-value => $user->name ) ) ),
$cgi->Tr( $cgi->th( {-align => left}, '' ),
$cgi->td( $cgi->password_field( -name => 'pwd',
-length => 24 ) ) ),
$cgi->Tr( $cgi->th( {-align => left}, '' ),
$cgi->td( $cgi->password_field( -name => 'pwd2',
-length => 24 ) ) ),
$cgi->Tr( $cgi->th( {-align => left}, '' ),
$cgi->td( $cgi->textfield( -name => 'email',
-value => $user->email ) ) ),
$cgi->end_table,
$cgi->submit( -value => '' ),
$cgi->end_form,
$cgi->end_html; |
...I erased a lot of Japanese text. You can even avoid all the '$cgi->' object calls if they bother you and just use the functional interface that CGI.pm borrowed from HTML::AsSubs. _________________ For every higher wall, there is a taller ladder |
|
Back to top |
|
|
phong Bodhisattva
Joined: 16 Jul 2002 Posts: 778 Location: Michigan - 15 & Ryan
|
Posted: Tue Sep 17, 2002 6:26 pm Post subject: |
|
|
To be honest, I write the HTML in most perl scripts by hand (usually big chunks with <<"BLOCK" style "here documents"). I write HTML files that way, so I'm used to it. In many cases, it's actually more readable, because you can see the exact HTML in your source. Of course, it's more readable to do it the CGI.pm way sometimes (with big scripts for example). And I use CGI.pm for handling form data, url parsing, cookies, etc. Actually, CGI.pm is a tad bloated for my taste, so if the script is small or simple, I forgo that entirely. _________________ "An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|