Hello,

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/EventLog.pm 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.

In reply to Reading Event Viewer by jonsey80

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.