Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Reading Event Viewer

by jonsey80 (Initiate)
on Jan 29, 2014 at 15:02 UTC ( #1072530=perlquestion: print w/replies, xml ) Need Help??
jonsey80 has asked for the wisdom of the Perl Monks concerning the following question:


I am new to perl and am trying to write a script which will search the system event viewer for 'disk' events, log the amount of alerts and write the message into a log file.

I have called the Win32::eventviewer module, and when i run this programme i get

Goto undefined subroutine &AutoLoader::AUTOLOAD at C:/Perl/lib/Win32/ line 50, <MYFILE> line 3.

I'm a bit lost at what is happening. the code is below:

calling the module:

use Win32::EventLog; # Module to access event Log for step 3
segment of code using event viewer:
$handle= New Win32::EventLog("System"); $i = 0; #sets up the counter for amount of alerts $count = 1; while($handle->read((EVENTLOG_SEEK_READ|EVENTLOG_FORWARDS_READ,$count, +$event))){ if($event->{source} eq 'disk'){ Win32::EventLog::GetMessageText($event); $i = $i +1; open(EVENT,'>Eventviewer.log') or die 'unable to open file'; print EVENT $event->{Message}."\n"; } else{ open(EVENT,'>Eventviewer.log') or die 'unable to open file'; print EVENT "No Disk errors Found"; } $count=$count+1; } $handle->Close
Eventually will print out the value of $i as well in a separate summary file as well as list all disk events in the eventviewer.log Any help on what im doing wrong would be appreciated - i have read the CPAN pages and anything else i can on this module but still at a lost. Thank you in advanced.

Replies are listed 'Best First'.
Re: Reading Event Viewer
by keszler (Priest) on Jan 29, 2014 at 19:21 UTC
    According to Win32::EventLog there is no read method. There is a Read method.
      had not noticed the caps - changed it to Read, made no difference error remains. thank you anyhow
        also the n in New should be new - which was causing the continuation of the error.
Re: Reading Event Viewer (MyEventLog)
by Anonymous Monk on Jan 29, 2014 at 21:11 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1072530]
Approved by Corion
[Tanktalus]: perldigious: I'm not looking to get rich. I'm looking for interesting work, with good continuity of employment, and maintenance of our current lifestyle. (An improvement wouldn't be bad, either, but that's not a requirement ;) )
erix enjoys the confusion++
[Your Mother]: :P
[Tanktalus]: Without confusion, I'd be out of a job ;)
[Tanktalus]: Already. :D
[Lady_Aleena]: Your Mother, I wish it did have a way to put in a directory to search.
[Your Mother]: Thatís silly. Itís a string op tool.
[Lady_Aleena]: So I guess I'll go argue with File::Find and grep.
[Your Mother]: I would probably use Path::Tiny instead for it's slurp and such.
[Your Mother]: s/it's/its/

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-05-23 19:37 GMT
Find Nodes?
    Voting Booth?