I do a fair amount of work with Win32::OLE and it's always a
good idea to check errors after certain operations. Otherwise,
debugging can be quite painful down the road, or if one OLE
call dies and snowballs. I use an OLE error checking sub like
so:
$obj=Win32::OLE->GetObject("IIS://localhost/W3SVC/1");
&OLEErrChk("Binding to W3SVC1",1)
That way you can also trap common errors and act on them, also.
sub OLEErrChk {
my $operation=shift;
my $critical=shift;
my $errnum=Win32::OLE->LastError;
if(!$errnum) {
if ($errnum=~/0x80070094/) {
print "$operation Failed (in use) trying something..\n";
&Something;
}
else {
print "$operation Failed: $errnum\n";
die if ($critical);
}
}
else {print "$operation was Successful.\n"}
}
Hope that helps,
Vlad