Warn This variable determines the behavior of the Win32::OLE modulewhen an error happens. Valid values are:
0 Ignore error, return undef
1 Carp::carp if $^W is set (-w option)
2 always Carp::carp
3 Carp::croakThe error number and message (without Carp line/module info) are available through the "Win32::OLE-"LastError> class method.
Alternatively the Warn option can be set to a CODE reference.
E.g.Win32::OLE->Option(Warn => 3); is equivalent to Win32::OLE->Option(Warn => \&Carp::croak); This can even be used to emulate the VisualBasic "On Error Goto Label" + construct: Win32::OLE->Option(Warn => sub {goto CheckError}); # ... your normal OLE code here ... CheckError: # ... your error handling code here ...
So, firing up an w32 box (w2k) and adding a shebang, #!C:/perl/bin -w, this is the output:
F:\_wo\pl_test>perl 696125.pl Win32::OLE(0.1701) error 0x80041002 after character 0 in "winmgmts:{impersonationlevel=impersonate,(Backup,Restore)}\\localhost +\root\wmi:BcdStore" at 696125.pl line 14 eval {...} called at 696125.pl line 14 Can't call method "OpenStore" on an undefined value at 696125.pl line +16.
And, compounding my demonstration of iggerance, as applied to your comment,
It looks like the previous line openstore is not assigning the store to $bcdst
I don't see how the openstore line would assign a value to a var declared without a value at your line 15.
UpdateFixed code tags
In reply to Re: Perl - WMI - BCD
by ww
in thread Perl - WMI - BCD
by ChrisLD
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |