Charles K. Clarkson wrote:
Gunnar Hjalmarsson wrote:
Personally I find CGI.pm's default way to access the parameters to
be clumsy. Just take the

    @{ [ $q->param('somename') ] }

construct that is needed for here documents and other
double-quotish contexts.

I rarely use it that way. I prefer templates for even small scripts. 'printf' solves this for small sections.

Okay, preferences and habits differ.

In reviewing scripts, I have found that most authors who convert the
CGI object to a hash also tend to use that hash throughout the script
without passing it to subroutines.

That's another topic, isn't it? Besides, is a file scoped CGI object better than a file scoped hash?

Look at the example Rocky presented. The "form" field was placed in a
hash and then into a scalar. It is likely that value was only tested
once. The same goes for the "action" field. Why jump through that
many hoops just in case we might maybe need a parameter in in a
double quoted statement somewhere down the line?

Well, I agree on some of your critizism of that script, and neither I see the point with also using scalar variables. I just find it convenient to use a hash (or a hash reference) to access name/value pairs.

Maybe this would have been sufficient:

    %ARGS = new CGI->Vars;

( or whatever would have been an appropriate name - maybe %in :) )

Had the author not relied on the hash to begin with, he might have
developed better programming skills for operating with objects.
Relying on the hash will certainly help him to avoid those skills.

Personally I find it much more important that beginner CGI programmers focus on things like validating the input properly and dealing with tainted mode. OOP is good to know, too, but not really necessary for handling CGI data, right?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to