[EMAIL PROTECTED] (Stas Bekman) wrote:
>> > It should be sufficient to do:
>> >
>> >   use mod_perl;
>> >   BEGIN { die "horribly" if $mod_perl::VERSION >= 2 }
>> >
>> > It's very handy to remember that 'use' is just 'require' and
>> > 'import' in a 'BEGIN' block.
>
>I don't think this is that simple, given that mod_perl.pm wasn't loaded
>yet.  BEGIN {} will take precedence and then $mod_perl::VERSION will be
>yet undef. I think the really clean way to go is :
>
>BEGIN { use mod_perl; }
>BEGIN { die "horribly" if $mod_perl::VERSION >= 2 }

No - the code I wrote is equivalent to:

  BEGIN { require mod_perl; import mod_perl; }
  BEGIN { die "horribly" if $mod_perl::VERSION >= 2 }

In other words, the 'use' happens at compile time, and then the BEGIN
happens after it (also at compile time).

I also agree with Geoff that his proposed idiom would be nice.  And the
man page does say, after all:

       no Module LIST
               See the the use entry elsewhere in this document
               function, which `no' is the opposite of.

(Isn't that embarassing?  "... the use entry elsewhere in this document
function."  Ah, podlators.)


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  [EMAIL PROTECTED]                            The Math Forum

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to