Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Coding superstitions

by kwoff (Friar)
on Jan 08, 2002 at 05:08 UTC ( #137017=note: print w/ replies, xml ) Need Help??


in reply to Coding superstitions

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. ;)


Comment on Re: Coding superstitions
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://137017]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2014-04-21 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (489 votes), past polls