This may not help much, but reading the Win32::OLE yields this nugget:
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::croak

The 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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.