[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-AnyPerl] Multi Platform Scripts



On Fri, Aug 13, 1999 at 11:19:21AM -0700, Vicki Brown wrote:
> OK, this works on my Mac:
> 
> BEGIN {
>     unless ($^O eq 'MacOS') {
>         unless (eval "use DBI") {
>             warn "Couldn't load module DBI\n";
>         }
>     }
> }
> 
> It doesn't try to load DBI and the syntax checking works. (Actually I've
> installed DBI on the Mac at work but not yet at home, so...)
> 
> The above code looks like the examples in the Cookbook (p. 403)
> 
> but on the Unix box I see
> 
>    Couldn't load module DBI
> 
> even though it actually seems to be loading.
> 
> I assume I've missed something obvious / done something stupid :-)
> But I don't see it. Please tell me what it is so I can say "Duh". :-/

use is a compile-time statement.  It has no value at runtime.  Aside from
the side-effect of loading DBI, eval "use DBI" is equivalent to eval "".

Try this instead:

        unless (eval "use DBI; 1") {

or, use require instead of use!

Ronald

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org