RE: setting the environment variables in perl

2004-07-27 Thread perl.org
On Tue, 27 Jul 2004 11:58:51 -0400, Bob Showalter wrote
> 
> It's really not a Perl issue per se. I assume you're talking about variables
> used by Oracle libraries, like ORACLE_HOME and ORACLE_SID.
> 
> I advise you to *not* attempt to set or monkey with these variables inside
> the Perl script. The whole point of environment variables is so the 
> user can establish his environment *before* invoking your script.

I agree with this in general, but sometimes the environment in which your Perl
runs cannot define these variables for you.  For instance, Interwoven TeamSite
Data Capture Template inline callout invocations clear all environment
variables before forking your process (the vendor claims this is for security
reasons).  For Oracle you must set ORACLE_HOME, etc, and for SQL Server you
have to define SYSTEMROOT or something like that or ODBC or whatever doesn't
work.  If coded, this logic of course belongs in a module.  

I also sometimes use environment variables to hold global configurables when
it is not feasible to pass these values to the subroutines that need them. 
It's faster for the subroutine to use an environment variable than to do a
lookup into a flat file to get some configuration info.  If I put this in the
environment before forking the process the space would be cluttered.  If
there's a better way to cache global confgiurables or other feedback on these
subjects I am all ears - I don't like using the environment, let alone setting
values that should be set elsewhere.

Thanks,

   -John


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: setting the environment variables in perl

2004-07-27 Thread u235sentinel
Good point in fact Oracle (for example) recommends setting the environment before you 
even install Oracle.  To do it any other way invites trouble and as Oracle would say, 
you're on your own :-)


> jason corbett wrote:
> > How does one go about assuring that the environment variables are
> > properly set in perl? I read several books, but none go in depth
> > about how to write a script that includes all the required variables,
> > that way nothing gets left out.
> 
> It's really not a Perl issue per se. I assume you're talking about variables
> used by Oracle libraries, like ORACLE_HOME and ORACLE_SID.
> 
> I advise you to *not* attempt to set or monkey with these variables inside
> the Perl script. The whole point of environment variables is so the user can
> establish his environment *before* invoking your script.
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: setting the environment variables in perl

2004-07-27 Thread Bob Showalter
jason corbett wrote:
> How does one go about assuring that the environment variables are
> properly set in perl? I read several books, but none go in depth
> about how to write a script that includes all the required variables,
> that way nothing gets left out.

It's really not a Perl issue per se. I assume you're talking about variables
used by Oracle libraries, like ORACLE_HOME and ORACLE_SID.

I advise you to *not* attempt to set or monkey with these variables inside
the Perl script. The whole point of environment variables is so the user can
establish his environment *before* invoking your script.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: setting the environment variables in perl

2004-07-27 Thread Flemming Greve Skovengaard
Paul Kraus wrote:
You can access all the env variables like this...
$ENV{ 'VAR' }
example
my $home = $ENV{ 'HOME' };
print "$home\n";
I have never tried to change them but I would assume
that it would work.
HTH,
Paul Kraus
On Tue, Jul 27, 2004 at 07:29:45AM -0700, jason corbett wrote:
How does one go about assuring that the environment variables are properly set in perl? I read several books, but none go in depth about how to write a script that includes all the required variables, that way nothing gets left out. 

Please advise.
JC
[snipet]
#!/usr/bin/perl -w
$ENV{"ORACLE_HOME"}="/orav101/oracle/8.1.7";
use strict; 
use DBI;
use lib '/home/samcsm/jason/myperl/lib/perl5/site_perl/';



Use this one-liner to check your environment variables:
perl -Mstrict -we 'foreach my $key (sort keys %ENV) { print "$key => 
$ENV{$key}\n" }'

--
Flemming Greve SkovengaardThe prophecy of the holy Norns
a.k.a Greven, TuxPowerthe world is doomed to die
<[EMAIL PROTECTED]>   fire in the sky
4112.38 BogoMIPS  the end is coming soon
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: setting the environment variables in perl

2004-07-27 Thread Paul Kraus
You can access all the env variables like this...

$ENV{ 'VAR' }

example
my $home = $ENV{ 'HOME' };
print "$home\n";

I have never tried to change them but I would assume
that it would work.

HTH,
Paul Kraus

On Tue, Jul 27, 2004 at 07:29:45AM -0700, jason corbett wrote:
> How does one go about assuring that the environment variables are properly set in 
> perl? I read several books, but none go in depth about how to write a script that 
> includes all the required variables, that way nothing gets left out. 
>  
> Please advise.
>  
> JC
>  
> [snipet]
>  
>  
> #!/usr/bin/perl -w
> 
> $ENV{"ORACLE_HOME"}="/orav101/oracle/8.1.7";
> 
> use strict; 
> use DBI;
> use lib '/home/samcsm/jason/myperl/lib/perl5/site_perl/';
> 
>  
> 


pgp1DvCvYBmPM.pgp
Description: PGP signature


setting the environment variables in perl

2004-07-27 Thread jason corbett
How does one go about assuring that the environment variables are properly set in 
perl? I read several books, but none go in depth about how to write a script that 
includes all the required variables, that way nothing gets left out. 
 
Please advise.
 
JC
 
[snipet]
 
 
#!/usr/bin/perl -w

$ENV{"ORACLE_HOME"}="/orav101/oracle/8.1.7";

use strict; 
use DBI;
use lib '/home/samcsm/jason/myperl/lib/perl5/site_perl/';