Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: : Charles K. Clarkson wrote: : : Many people seem to have a penchant for placing the CGI object : : parameters inside a hash. Personally, I find this a poor : : practice. : : Isn't it rather a very natural Perl practice to store a bunch : of name/value pairs in a hash? : : 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. 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. Since this is a beginners list I tend to frown on practices that accompany each other. Getting into the habit of changing the CGI object into a hash at the top of a script, where we can assume it was in the snippet given, is a poor idea. Do it as needed would be a better practice. 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? 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. Had this been a different list or had Rocky indicated he was an advanced perl programmer I might phrase this differently, but on this perl beginners list I find the practice of converting a CGI object to a hash at the top of the script to be a poor practice for beginners to follow. : : And the object can be changed as easily as a hash. : : Disagree on that, too. I can see your point here, but I rarely need to change enough parameter values to warrant changing an object to a hash. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>