develooper Front page | perl.beginners | Postings from May 2010

Re: How to set LD_LIBRARY_PATH

Thread Previous | Thread Next
Shlomi Fish
May 28, 2010 01:07
Re: How to set LD_LIBRARY_PATH
Message ID:
On Friday 28 May 2010 10:45:14 newbie01 perl wrote:
> Hi all,
> Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?
> If I set LD_LIBRARY_PATH from the command line, all is okay
> [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
> Can't load
> '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi
> /auto/DBD/Oracle/' for module DBD::Oracle:
> cannot open shared object file: No such file or directory at
> /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/ line 230.
> at -e line 1
> Compilation failed in require at -e line 1.
> BEGIN failed--compilation aborted at -e line 1.
> [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
> [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
> 1.15
> But if I do the following instead in the Perl script, it does not work? How
> to set the LD_LIBRARY_PATH then?
> FYI, the script is to run from a cron which is why am setting
> LD_LIBRARY_PATH in the script.

If you're going to use "use DBD::Oracle;" in the script then you'll need to 
put these statements in a BEGIN block:

use vars qw($ORACLE_HOME $ORACLE_SID);

	$ORACLE_HOME = ...;
	$ORACLE_SID = ...;

use DBD::Oracle;

That's because "use" is executed at compile-time instead of run-time.


	Shlomi Fish

Shlomi Fish
"The Human Hacking Field Guide" -

God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.

Please reply to list if it's a mailing list post - .

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About