[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "static" declaration

>   More broadly, the lack of declarations in Perl makes it a lot harder
>   to read the code.  

Yes.. it's not merely the lack of declarations. It is (as you point
out) "implicit" declarations that lead to scope capture, over-writing
etc. -- I benchmarked at one time that about 60-70% of our bugs in
"newly deployed" Perl code was due to this single issue. Simple typos
where a single character in a variable's name was transposed or
mistyped etc. wreak havoc.

To make your life easier.. whenever you "read" code.. clean it
up. Pull all the variable declarations to the top (of file and
function/method). Introduce a comment to reference the "globals" (yes,
Perl programmers seem to be awfully fond of them). Use conventions
(any convention is better than nothing) for naming. Always run with
the highest level of checking and warnings that perl can give you. If
you don't do these things, your life with said perl code will never
get better.