D
davids
I have a Perl/Tk program that uses the Win32::OLE modules to read
and write Excel spreadsheets. Actually, that is just an accessory
function. The purpose of the program is to take data from a set
of instruments.
Anyhow, the program includes statements like this:
1. use Win32::OLE::Const 'Microsoft Excel';
and later, buried in a subroutine, statements like:
2. $worksheet->PageSetup->{PaperSize} = xlPaperLetter;
The problem is at statement 1 - perl complains that
No type library matching "MicrosoftExcel" found ....
and at statement 2 -
Bareword 'xlPaperLetter' not allowed while 'strict subs' in use ...
and the program refuses to run. This happens on any computer that
Excel is not installed on.
My question is: What can I put in the code to cause it to not
use this Excel-only code if it doesn't have Excel installed.
My question is how can I detect whether Excel is installed at
run-time and skip compiling the subroutines containing these
statements based on it.
I realize that I can just comment them out and have two
versions of the program, but is there a clever way to do
it in Perl?
I've run into this problem in a different context where
I'd like to run the program on a computer that doesn't have
the instrument drivers installed - but I'd still like to
run it and use the data visualization features to review
measurement results.
Any hints appreciated.
Thanks,
Dave Smith
and write Excel spreadsheets. Actually, that is just an accessory
function. The purpose of the program is to take data from a set
of instruments.
Anyhow, the program includes statements like this:
1. use Win32::OLE::Const 'Microsoft Excel';
and later, buried in a subroutine, statements like:
2. $worksheet->PageSetup->{PaperSize} = xlPaperLetter;
The problem is at statement 1 - perl complains that
No type library matching "MicrosoftExcel" found ....
and at statement 2 -
Bareword 'xlPaperLetter' not allowed while 'strict subs' in use ...
and the program refuses to run. This happens on any computer that
Excel is not installed on.
My question is: What can I put in the code to cause it to not
use this Excel-only code if it doesn't have Excel installed.
My question is how can I detect whether Excel is installed at
run-time and skip compiling the subroutines containing these
statements based on it.
I realize that I can just comment them out and have two
versions of the program, but is there a clever way to do
it in Perl?
I've run into this problem in a different context where
I'd like to run the program on a computer that doesn't have
the instrument drivers installed - but I'd still like to
run it and use the data visualization features to review
measurement results.
Any hints appreciated.
Thanks,
Dave Smith