lisa2moon has asked for the wisdom of the Perl Monks concerning the following question:
use Win32::OLE; my $book; my $sheet; my $sheet_name = "rota"; my $rota_location = 'e:/rota.xls'; if( -e $rota_location ){ $book = $ex->Workbooks->open($rota_location); }else{ $book = $ex->Workbooks->Add; } unless($sheet = eval { $book->Worksheets($sheet_name) }){ $sheet = $book->Worksheets->Add; $sheet->{Name} = $sheet_name; }
Using eval { $book->Worksheets($sheet_name) }, I want eval catch the error if the sheet doesn't exist. But the method doesn't work. when the sheet doesn't exist,the perl showes the following error:
Win32::OLE(0.1701) error 0x8002000b: "" in METHOD/PROPERTYGET "Worksheets" at create_rota.pl line 48
I'll appreciate your help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why cann't $@ output the eval error in this case?
by ELISHEVA (Prior) on Jan 05, 2011 at 10:52 UTC | |
by moritz (Cardinal) on Jan 05, 2011 at 11:31 UTC | |
by lisa2moon (Initiate) on Jan 05, 2011 at 11:40 UTC | |
|
Re: why can't $@ output the eval error in this case?
by moritz (Cardinal) on Jan 05, 2011 at 10:42 UTC | |
|
Re: why cann't $@ output the eval error in this case?
by Anonymous Monk on Jan 05, 2011 at 10:36 UTC |