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'
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.