|XP is just a number|
Re: Re: Re: Problem with tie *STDIN, 'IO::Scalar', \$text;by LunaticLeo (Scribe)
|on Apr 30, 2001 at 20:36 UTC||Need Help??|
I think you have overlooked some major diabolical evil :).
Named blocks, as opposed to functions, HIDE the external effects of the block from the reader. Using the name of the block as some kind of documentation feature is a poor choice.
Even if you want your subroutine to affect globals, you can pass globals in and return new values for globals. This "documents" your named block even better; explicitly telling the reader what this chunk of code depends on and what it changes.
is MUCH better than:
I have had to read code like this (and it is very hard):
This was horrible. I was tempted to just remove the "sub" lines, but then I noticed the subs were not declared in the order they were used. As I paid more attention, some variables inside the subs were my()'ed but had the same name as globals.
We had to audit this code to make sure it was calculating money dispusements correctly. How can you audit this code?
It was painfull to read, impossible to audit, and such a rats nest it was difficult to modify. I lay most of the blame at the fact that it was using globals, locals, and named blocks. Writing functions force a certain amount of structure. Even if the structure is lame it is emminently more readable and auditable.