Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

CGI.pm HTML shortcuts

by petdance (Parson)
on Apr 20, 2001 at 00:40 UTC ( #73986=note: print w/ replies, xml ) Need Help??


in reply to CGI.pm HTML shortcuts

Well, of course there's no way that generating code programatically is going to be any faster than static strings. However, I have to say it over and over: Speed is not everything. Before you worry about speed, figure out how slow your solution is. Chances are it's unnoticeable.

print start_html( PAGE_TITLE ), h1( PAGE_TITLE ), start_form( -method=>"GET", -action=>$q->self_url ), input( {type=>"text",name=>"text",size=>40, value=>$text} ), input( {type=>"text",name=>"width",size=>5, value=>$width} ), +" pixels wide", submit( -value=>"Muck!" ), end_form(), table( {border=>1,cellspacing=>0,cellpadding=>0}, Tr( th( "Original" ), th( "Mucked" ) ), Tr( td( img( {src=>$filename} ) ), td( img( {src=>"mucked-$filename"} ) ), ), # tr ), # table end_html();
You can see the entire structure of the page right there. I can't goof up closing TABLE tags (a particular bane of Netscape), everything has to be well-formed, etc etc etc. Is that worth a few milliseconds of execution time? In my book, yes.

xoxo,
Andy

# Andy Lester  http://www.petdance.com  AIM:petdance
%_=split';','.; Perl ;@;st a;m;ker;p;not;o;hac;t;her;y;ju';
print map $_{$_}, split //,
'andy@petdance.com'


Comment on CGI.pm HTML shortcuts
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2014-09-16 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (34 votes), past polls