You'd get that error if Perl was unable to find the Win32::EventLog class at runtime. E.g. if you create a script containing only the following, you can reproduce the error;
my $handle = Win32::EventLog->new("Application", $ENV{ComputerName});
ActivePerl doesn't seem come with Win32::EventLog by default - I just had to install in manually.
You can check whether it's installed by looking for the file;
C:\Perl\site\lib\Win32\EventLog.pm
(Assuming you installed ActivePerl to C:\Perl). The C:\Perl\site directory is where additional libraries, e.g. from CPAN, get installed while C:\Perl\lib is where the default libraries, bundled with Perl, are installed.
If it's not there, you'd need to install it - from the command line you start the ActiveState package manager then install the Win32::EventLogs;
C:\> ppm
ppm> install Win32::EventLog
I assume you're not behind a proxy server. If you are you'd first need to setup your proxy environment in DOS, before running the above commands e.g.;
REM proxy.bat - set's up proxy environment vars
@echo off
set HTTP_proxy=http://your.company.proxy.com:8080/
set HTTP_proxy_user=user
set HTTP_proxy_pass=passwd
If Win32::EventLog is installed, then you need to check you have the correct use statement at the start of the script;
use strict;
use Win32::EventLog;
If Perl can't find it in it's library paths, it should raise an error at this point e.g.
Can't locate Win32/EventLog.pm in @INC (@INC contains: c:/Perl/lib c:/
+Perl/site/lib .) at print_log.pl line 2.
BEGIN failed--compilation aborted at print_.pl line 2.
If you get that, run the following and post it here;
use Data::Dumper;
print Dumper(@INC);
For a standard ActivePerl install you should see;
$VAR1 = 'c:/Perl/lib';
$VAR2 = 'c:/Perl/site/lib';
$VAR3 = '.';
|