Rev 229 | Rev 261 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#! perl######################################################################### Copyright ( C ) 2006 ERG Limited, All rights reserved## Module name : jats.sh# Module type : Makefile system# Compiler(s) : n/a# Environment(s): jats## Description : Provide some misc environment functions# Note this is not a "package" as we will be importing# variables directly into the users space.## Usage:## Version Who Date Description##......................................................................#require 5.006_001;use strict;use warnings;use JatsError;#-------------------------------------------------------------------------------# Function : EnvImport## Description : Import an environment variable into the current user space# The user should have pre-declared the usage of the variable# with an "our". For this reason this package is not a# 'package'. Rather it is simply imported.## Inputs : Name of the environment varibale to import## Returns : 1# If the variable is not present then an error message is# generated and the program will be termianted. The assumption# is tha the variable MUST be present.#sub EnvImport{my( $EnvVar ) = @_;no strict 'refs';unless ( defined( $$EnvVar ) ) {$$EnvVar = $ENV{ $EnvVar };}Error( "Environment Variable '$EnvVar' not defined." )unless( defined $$EnvVar );use strict;return 1;}#-------------------------------------------------------------------------------# Function : EnvImportOptional## Description : Import an environment variable into the current user space# The user should have pre-declared the usage of the variable# with an "our". For this reason this package is not a# 'package'. Rather it is simply imported.## If no default value is provided and the variable does not# exist in the environment, then result will be undefined## Inputs : Name of the environment varibale to import# Default value## Returns : 1#sub EnvImportOptional{my( $EnvVar, $DefaultValue ) = @_;my $value = $ENV{ $EnvVar } || $DefaultValue;no strict 'refs';unless ( defined( $$EnvVar ) ) {$$EnvVar = $value;}use strict;return 1;}1;