Syntactic Confectionery Delight | |
PerlMonks |
Re: A Matter of Style in CGIby Flexx (Pilgrim) |
on Sep 12, 2002 at 20:07 UTC ( [id://197333]=note: print w/replies, xml ) | Need Help?? |
Hi! I got some thoughts on your script, I'd like to share with you. You dared to ask, so you deserve no better. HARHAR!! ;) Not all of it is CGI-related, but nonetheless I hope it's interesting.
This is fine. I do not know mySQL (our DB folks like Oracle ;), but if it supports bind variables in the ORDER BY clause, you could say:
Using prepare_cached might save you some milliseconds, if mySQL allows for it. If cached, using a placeholder in the ORDER BY clause will allow to have the statement cached independent from the sort column. Unless you need the value of $sort elsewhere you could even say: $sth->execute($q->param('sort') || 'emp_last')to leave things in place. Also, having sort double quoted is a waste of time, at least of optimizer time, but that's pernickety. ;) Just as a matter of taste, I like to put my SQL statments in here docs, as above.
Wouldn't you wan't have all those style attributes defined in the stylesheet you link to? Even if the imported stylesheet is not in your hands, you could define your styles in a dedicated style tag in the head section of the generated output:
Note that CGI.pm also provides a span() function allowing you to apply a class / style definition to multiple elements (which would save some of your HTML span tags). I am not sure, however, if that works in the OO interface, too. You hard-code the (own) script name several times:
Don't. Either use my $SCRIPT_NAME = 'emp_list.cgi' at file scope near the top of your file, so you'd have to change that only once if it changes. Even better is to use $q->script_name() for that. That way, you can rename the script file without having to change anything. Use as few literals as possible. Early in your script use:
Actually, I like have such definitions in a CONF.pm and use that. Running under mod_perl, this will even save a bit memory making these variables shared.
Consider:
Hope this helps/is interesting,
In Section
Seekers of Perl Wisdom
|
|