Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
html output in Perl?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
neko
n00b
n00b


Joined: 14 May 2002
Posts: 9
Location: UCSD

PostPosted: Tue Sep 17, 2002 4:13 pm    Post subject: html output in Perl? Reply with quote

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
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Tue Sep 17, 2002 6:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
phong
Bodhisattva
Bodhisattva


Joined: 16 Jul 2002
Posts: 778
Location: Michigan - 15 & Ryan

PostPosted: Tue Sep 17, 2002 6:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
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