Comment: Scope bashing? (Score 1) on 2009.10.18 12:57
by
oylenshpeegul
on 2009.10.18 12:57
(#70913)
Attached to: Declarations and Scope followup on Chromatic's post
Attached to: Declarations and Scope followup on Chromatic's post
Calling my comment on SO "scope bashing" is unfair. I'm all in favor of scoping everything as tightly as possible. Indeed, I agree with everything in chromatic's post. But I still think the practice of wrapping a Perl script in a main subroutine is not "best" or even good. I maintain it's an antipattern that indicates the author is a C programmer, not a Perl programmer.
In chromatic's example, $sth has tighter scope than the other variables, but in the first case, it's declared along with the rest. Wrapping the whole thing in a subroutine doesn't change that. You still have to do everything he talked about.
Read More
5 comments
