Do something like this:
###########
Win32::OLE->Option(Warn => \&Error_Handler);
sub Error_Handler{
print "WARN!!! ".Win32::OLE->LastError."\n";
}
##########
-----Original Message-----
From: Gallagher, Tim (NE) [mailto:[EMAIL PROTECTED]
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 GetBIOS
{
my @arryBIOS;
my($strComputer) = @_;
$objWMIService = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer .
'\\root\\CIMV2');
$colItems = $objWMIService->ExecQuery('SELECT * FROM Win32_BIOS',
undef, 48);
foreach my $objItem (in $colItems) {
print $objItem->Manufacturer . "& " . $objItem->SerialNumber;
return $objItem->Manufacturer . "& " . $objItem->SerialNumber;
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>