--- Dave Chappell <[EMAIL PROTECTED]> wrote:
> I am creating a script that runs both on win9x and NT/2000/XP and based
> on which OS the script is run on, certain OS specific features are
> performed with modules like Win32::Service. When I run the script in a
> Win9x environment I get an error; "The Win32::Service module works only
> on Windows NT". Is there a way to tell perl which load modules based on
> OS at script start-up/compilation?

Dave,

You'll have to figure out how to distinguish between the different versions of the OS. 
 If I use
this:

    perl -e "print $^O"

I get "MSWin32".  However, I think the ENV variable "OS" does the trick (I just 
checked while
writing the email).  Thus:

  BEGIN {
    if ( exists $ENV{'OS'} and $ENV{'OS'} eq 'Windows_NT' ) {
      require Win32::Service;

      # if any functions are imported into your namespace or you need
      # to specify an import list:
      Win32::Service->import; 
    }
  }

Cheers,
Curtis "Ovid" Poe


=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

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

Reply via email to