Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: don't understand bless

by pc88mxer (Vicar)
on Mar 26, 2008 at 15:23 UTC ( [id://676424]=note: print w/replies, xml ) Need Help??


in reply to don't understand bless

I would check the value of $Excel to see if it is what you think it is. From the perlop man page:
$a = $b or $c; # bug: this is wrong ($a = $b) or $c; # really means this $a = $b || $c; # better written this way

Replies are listed 'Best First'.
Re^2: don't understand bless
by kyle (Abbot) on Mar 26, 2008 at 15:47 UTC

    I think your suggestion to check the value of $Excel is a good one. However, the reference to perlop doesn't seem relevant here.

    I'm guessing you're talking about this bit:

    my $Excel = Win32::OLE->GetActiveObject('Excel.Application') or Win32::OLE->new('Excel.Application', 'Quit') or die "Could not start excel";

    This doesn't look like a $x = $y || $z assignment to me. It looks as if it's trying to GetActiveObject(), and if that fails, try to quit Excel. If that fails, just die.

    Now that I look at it, the problem may be that GetActiveObject() fails, quitting Excel succeeds, and the script then doesn't die. It goes on to try to use (the bogus) $Excel anyway. So I'd try this:

    my $Excel = Win32::OLE->GetActiveObject('Excel.Application'); if ( ! $Excel ) { Win32::OLE->new('Excel.Application', 'Quit'); die 'Could not start Excel'; }

      If using or was truly desired,

      my $Excel = Win32::OLE->GetActiveObject('Excel.Application') or do { Win32::OLE->new('Excel.Application', 'Quit'); die "Could not start excel"; };

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://676424]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-23 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found