I would disagree about using the OO form for the html subs. It's gets ugly quick. Though you would need it for form inputs if you have multiple objects (That or local $CGI::Q = $cgi; before the form fields)
-Lee
"To be civilized is to deny one's nature."
Update
To be honest, I'm suprised this was down-voted. I'm curious what the arguments for this
print header(),
table ({-border=> "0", -width=> "340"},
Tr ({-valign=> "top"},
td (
font ({-face=> "verdana,arial"},
" Column One ",
), "\n",
), "\n",
td (
font ({-face=> "verdana,arial"},
" Column Two ",
), "\n",
), "\n",
), "\n",
Tr ({-valign=> "top"},
td (
font ({-face=> "verdana,arial"},
" Data ",
), "\n",
), "\n",
td (
font ({-face=> "verdana,arial"},
" Data ",
), "\n",
), "\n",
), "\n",
), "\n",
;
verse this are
print $cgi->header(),
$cgi->table ({-border=> "0", -width=> "340"},
$cgi->Tr ({-valign=> "top"},
$cgi->td (
$cgi->font ({-face=> "verdana,arial"},
" Column One ",
), "\n",
), "\n",
$cgi->td (
$cgi->font ({-face=> "verdana,arial"},
" Column Two ",
), "\n",
), "\n",
), "\n",
$cgi->Tr ({-valign=> "top"},
$cgi->td (
$cgi->font ({-face=> "verdana,arial"},
" Data ",
), "\n",
), "\n",
$cgi->td (
$cgi->font ({-face=> "verdana,arial"},
" Data ",
), "\n",
), "\n",
), "\n",
), "\n",
;
They are both functionally equivalent for non-form fields, only the first is more shorter and clearer to read. Unless you are subclassing CGI.pm and have special instance specific stuff tied to the HTML generation of non-form fields, why would you use the latter? |