Can't you just turn your for loop into a hash reference instead of an array
ref as such?

%eventlogs = ("Application" => 'appevent.evt',
              "System"      => 'system.evt', #not sure of filenames
              "Security"    => 'security.evt' #not sure of filenames
             );

for my $eventLog (sort keys %eventlogs) {
  my $dbase = $eventlogs{$eventlog};
  $handle=Win32::EventLog->new($eventLog, $myServer) or die "Can't open
$eventlog EventLog on $myServer\n";
  .....
  .....
}

Maybe I am missing the point..

Steven
-----Original Message-----
From: Bryan, Tom Team EITC [mailto:[EMAIL PROTECTED]] 
Sent: Friday, January 31, 2003 4:42 PM
To: [EMAIL PROTECTED]
Subject: eventlog help


I am trying to query the actual .evt file size for each eventlog, and backup
and clear if the log is over 200mb.  This all works pretty well, but I set a
value for the dbase to check(ie: appevents.evt) each time through.  I am
using the code below.  Is there a way to set $dbase equal to appevent.evt
the first time, sysevent.evt the second time, and secevent.evt the final
time through the loop??  Any comments appreciated. 

###############  CODE SNIPPET BELOW  ##########################


use Win32::EventLog;
my($date)=join("-", ((split(/\s+/, scalar(localtime)))[0,1,2,4]));
my($dest);
$dBase = "?????????????????";

$myServer = "\\\\servername";
for my $eventLog ("Application", "System", "Security") {
        $handle=Win32::EventLog->new($eventLog, $myServer)
                or die "Can't open Application EventLog on $myServer\n";
        $dest="C:\\BackupEventLogs\\$eventLog\\$date.evt";
        $logsize="C:\\winnt\\system32\\config\\$dBase";

          if ( -s $logsize >= 200000000 ) {
        $handle->Clear($dest)
                or warn "Could not backup and clear the $eventLog EventLog
on $myServer ($^E)\n";
        print "Backing up $eventLog log on $myServer...\n";
          }
        $handle->Close;
}

#############  END CODE SNIPPET  ###############################

Tom Bryan
Systems Administrator
USSOCOM/Team EITC _______________________________________________
Perl-Win32-Users mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to