in reply to A Matter of Style in CGI

Rather than mix n' matching hardcoded HTML and CGI's HTML shortcuts, consider using just the latter for consistency ...

# <link rel='stylesheet' href='/styles/hr.css' type='text/css' /> $q->start_html( -title => 'Employee Table', # etc.. -style => { src => '/styles/hr.css' }, ), # <span class=section-heading>Employee Table</span> $q->span({-class=>"col-heading"},"Employee Table"),

You may also want to remove quotes from strings made up solely of a lone scalar (ie, $emp_id vs. "$emp_id"), as the interpolation of such serves no purpose.

Lastly, to expand on comments by dws and Zaxo, take a look at using placeholders in your SQL.

    --k.


Replies are listed 'Best First'.
Re^2: A Matter of Style in CGI
by Aristotle (Chancellor) on Sep 12, 2002 at 20:20 UTC
    .. remove quotes from strings made up solely of a lone scalar (..), as the interpolation of such serves no purpose.

    Good catch; I'd go even further with that advice and say you should never do it unless you know why not. It can potentially be very harmful since it stringifies anything: references are flattened into useless text. That's very unlikely to be something you are intending. In the case of other kinds of scalar values, it's no harm, however neither does it do anything useful.

    So while it doesn't necessarily hurt, it doesn't gain you anything either. And occasionally it can hurt big time. Bottom line, don't do it.

    Makeshifts last the longest.