Trapping errors
0 answers - 1113 bytes -

Do something like this:
Win32::LE->(Warn =\&Error_Handler);
sub Error_Handler{
print "WARN!!! ".Win32::LE->LastError."\n";
}
Message
From: Gallagher, Tim (NE) [mailto:Tim.Gallagher (AT) gd-ais (DOT) com]
Sent: Wednesday, May 10, 2006 11:20 AM
To: Perl Beginners
Subject: Trapping errors
I am using wmi within Perl and if I get any errors the script will die I don't want to script to die, I want the script to continue.
Here is part of my script and if any of these lines has a problem the script dies. How can I trap the errors and keep the script going?
Thanks
-T
sub GetBIS
{
my @arryBIS;
my($strComputer) = @_;
$objWMIService = Win32::LE->G('winmgmts:\\\\' . $strComputer '\\root\\CIMV2');
$colItems = $objWMIService->ExecQuery('SELECT * FRM Win32_BIS', undef, 48);
foreach my $objItem (in $colItems) {
print $objItem->Manufacturer . "& " . $objItem->SerialNumber;
return $objItem->Manufacturer . "& " . $objItem->SerialNumber;
}
}
*