Octavian Rasnita wrote at Fri, 07 Jun 2002 05:00:33 +0200:

> ... 
> The important code with problem is:
> 
> if ($^O =~ /MSWin/i) {
> print "The OS is: $^O";
> #This line is not printed because the OS is Linux but the following line has 
>problems 
> use Net::SMTP;
> ...
> How can I avoid Linux complaining that there is no Net::SMTP module installed even 
>though I've
> tested not  to be necessary?
> 

The problem is that a use Net::SMTP; statetement is evaluated at compile time. 
That means even if you write something like 
if (0) {
  use foo;
}
The compiler will try to load foo;

You can avoid it with using require:
if ($^O =~ /MSWin/i) {
   ...
   require 'Net::SMTP';
   Net::SMTP::import();
}

Require is evaluated at run time.
Note that the import call is necassary.


Best Wishes,
Janek

PS: BTW, it's better when the subject gives a short description of the problem.
Of course, you're asking What am I doing wrong ? because you posted in beginners.cgi.
:-)


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

Reply via email to