Can't locate Win32/ in @INC (@INC contains:

I am trying to use same perl script both on Windows and Unix enviornment, it works on windows fine but I get below error on Unix

Can't locate Win32/ in @INC (@INC contains: /home/s/lib /usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2 /usr/opt/perl5/lib/site_perl .) at line 25.
BEGIN failed--compilation aborted

on at line 25 I have this entry
use Win32::Service;

I have to comment out above line in order to make it work on Unix, is there a way that I could run the same perl script with having 2 verions (windows and Unix) of it?
I would appreciate your help
Who is Participating?
MorcalavinConnect With a Mentor Commented:
I don't know the best solution, but I use this on a few scripts.

        if($^O eq "MSWin32")
                require Win32::Service;
It's worth noting that Win32::Service is only going to work on windows systems, so if you try to make use of it in unix it's going to croak.
The code for Morcalavin will let your script run, but there will likely be other errors if you use any functions from the Win32::Service module.

What is it that the script does on windows?  What do you want it to do on unix?
What windows calls services are what unix calls daemons.  Do you want to monitor a daemon process?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.