I am trying to set some environment variables in Perl at the very beginning of the program, but I keep receiving errors unless I set them in a Bash script that calls my Perl script.
#!/usr/bin/perl -w
$ENV{'ORACLE_HOME'}='path';
$ENV{'LD_LIBRARY_PATH'}='path';
This does not work, but my shell script does:
#!/bin/bash
export ORACLE_HOME=path
export LD_LIBRARY_PATH=path
./perlscript.pl
I am setting these paths in order to get my DBI module to work. Ideally, I would like to set the paths in the Perl script and not use a Bash script.
Error:
Install_driver (Oracle) failed: Can't load /some/path/ for module DBD:Oracle: libclntsh.so.11.1: Cannot open shared object file: No such file or directory at /some/path/DynaLoader.pm line 230
Code
use DBI;
my $dbh = DBI->connect("DBI:Oracle:host=something;port=something;sid=something");
my $sth = $dbh->perepare($query);
$sth->execute();
$sth->finish();