Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Coding superstitionsby kwoff (Friar) |
on Jan 08, 2002 at 05:08 UTC ( [id://137017]=note: print w/replies, xml ) | Need Help?? |
I always quote the key left of an `=>'. It's because
I had bad experiences with earlier perl version with CGI.pm,
where things like $q->popup_menu(-values=>[...]) would
give a warning and it took a long time for me to
figure out that `values' is a perl function. :)
I think the way I figure things out, and it's a bit cargo-cultish; if I can't find what's causing the problem but I found something that stops the problem, then in the back of my mind I avoid doing whatever caused the problem. It sometimes comes back to bite you though, because you didn't take the time to figure out WHY there was a problem; or otherwise, you will end up spending lots of time and energy approaching a problem a certain way just because you try to avoid the "dangerous" method. So, like you say, you have these little superstitions. Then later you might accidentally discover the real cause, and those are happy moments of revelation. AHA! I thought of another example of mine. I single-quote as much as I can, in the back of my mind thinking that maybe I'm saving a few cycles by not interpolating a double-quoted string. :) I also always use qq{} for writing SQL or HTML strings. The reason for `qq' is often there are embedded quotes in HTML, and I forget to change the outside quotes. The reason for `{}' is in SQL there are often parentheses. I try to find the most general quotation for all cases to be consistent. Also I tend to overuse CODE tags in perlmonks. ;)
In Section
Meditations
|
|