http://qs321.pair.com?node_id=676433


in reply to Re: don't understand bless
in thread don't understand bless

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'; }

Replies are listed 'Best First'.
Re^3: don't understand bless
by ikegami (Patriarch) on Mar 26, 2008 at 18:12 UTC

    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"; };