[27604] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9112 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 1 09:05:51 2006

Date: Sat, 1 Apr 2006 06:05:03 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 1 Apr 2006     Volume: 10 Number: 9112

Today's topics:
        How to do conditional compile. <nobody@nowhere.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 31 Mar 2006 21:03:16 -0800
From: davids <nobody@nowhere.com>
Subject: How to do conditional compile.
Message-Id: <aqadncftzIsIlLPZnZ2dnUVZ_sOdnZ2d@comcast.com>

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 

   


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9112
***************************************


home help back first fref pref prev next nref lref last post