On Fri, 25 May 2001, Ken Williams wrote:
> [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).
blushed and embarrassed. sigh :(
I've always interpreted "as soon as possible" as first thing, first.
A "BEGIN" subroutine is executed as soon as possible, that
is, the moment it is completely defined, even before the
rest of the containing file is parsed. You may ha
but then you are right that use() expands to a BEGIN block.
> 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.)
reverse polish notation?
my_code:
---------
use dont;
dont.pm:
--------
use mod_perl; BEGIN { die "horribly" if $mod_perl::VERSION >= 2 }
:)
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]