>>>>> "Maxim" == Maxim Berlin <[EMAIL PROTECTED]> writes:

Maxim> Hello Tamir,
Maxim> Wednesday, June 27, 2001, Hasanuddin Tamir <[EMAIL PROTECTED]> wrote:

>>> if ( $OS ne "NT" )
>>> {
>>> BEGIN { unshift(@INC,"/usr/local/etc"); }
>>> require "config.backup.pl";
>>> }

HT> The BEGIN blocks always execute first no matter where you put them.
Maxim> yes, of course. BEGIN was placed inside just for better readability.

I actually consider that *less* readable and maintainable, because it
would lead someone to believe that the BEGIN block somehow depended on
that condition, which it doesn't.

I'd flunk it in one of our professional code reviews, in other words.
At least not without a big honkin' comment that says "THIS EXECUTES
ANYWAY, REGARDLESS OF THE ABOVE CONDITION.  WE PUT IT HERE BECAUSE WE
WANTED TO, NOT BECAUSE IT MAKES SENSE".  Usually, if a developer is
told to do that as an alternative to moving it, they just move it.

Then again, in a code review, I'm required to be an advocate for the
unseen maintenance programmer who is usually not as clever as the
original author. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Reply via email to