Thanks Darin,

Actually, because I 'use strict',  option 2 failed with compile errors like:
Bareword "ORA_RSET" not allowed while "strict subs" in use at ....

So I will perservere with re-organising my program so option 1 will work

Michael Fox

-----Original Message-----
From: Darin McBride [mailto:darin@;naboo.to.org]
Sent: Wednesday, November 06, 2002 11:33 AM
To: [EMAIL PROTECTED]
Subject: Re: use DBD::Oracle qw(:ora_types); - from cron


On November 5, 2002 04:41 pm, you wrote:
> When I need to have a "use DBD::Oracle qw(:ora_types);" in my program, and
> I am running from cron, I get a message like:
>
> Can't load '<long path>/auto/DBD/Oracle/Oracle.so' for module
DBD::Oracle:'
> at the use DBD::Oracle line.
>
> Other programs that just have a 'use DBI' are fine.  The normal program
> structure I have so that programs work from cron is like:
>
> use DBI;
> ....
> <setup Oracle variables, including LD_LIBRARY_PATH>
> ....
> $dbh=DBI->connect($dsn, $username, $password, { ora_module_name => $me })
> ....
> etc
>
> but as soon as I add;
>
>  use DBD::Oracle qw(:ora_types);
>
> I get the error, because the symbol import is done at compile time, before
> my program has had a chance to set up the environment properly.
>
> Any ideas how to get around this problem?  So far I am explicitly setting
> LD_LIBRARY_PATH in the crontab entry, but I was trying to have it all
> happen inside the program.

Two basic ideas:

BEGIN { <setup Oracle variables, etc.> }
use DBD::Oracle qw(:ora_types);

or:

eval 'use DBD::Oracle qw(:ora_types)';
die $@ if $@;

The first one gets your environment set up before the use, since BEGIN
is executed during compilation, while the second option will delay the
compilation of the use DBD::Oracle until the eval is reached. 
Personally, I would suggest the first option where possible.

> Australia Post is committed to providing our customers with excellent
> service. If we can assist you in any way please either telephone 13 13 18
> or visit our website www.auspost.com.au.
>
> CAUTION
>
> This e-mail and any files transmitted with it are privileged and
> confidential information intended for the use of the addressee. The

Which addressee?  :-)

> confidentiality and/or privilege in this e-mail is not waived, lost or
> destroyed if it has been transmitted to you in error. If you have received
> this e-mail in error you must (a) not disseminate, copy or take any action
> in reliance on it; (b) please notify Australia Post immediately by return
> e-mail to the sender; and (c) please delete the original e-mail.



Australia Post is committed to providing our customers with excellent service. If we 
can assist you in any way please either telephone 13 13 18 or visit our website 
www.auspost.com.au.

CAUTION

This e-mail and any files transmitted with it are privileged and confidential 
information intended for the use of the addressee. The confidentiality and/or 
privilege in this e-mail is not waived, lost or destroyed if it has been transmitted 
to you in error. If you have received this e-mail in error you must (a) not 
disseminate, copy or take any action in reliance on it; (b) please notify Australia 
Post immediately by return e-mail to the sender; and (c) please delete the original 
e-mail.

Reply via email to