=head1 NAME

CFX5::Config::Environment - package for composing ANSYS environment variables.

=head1 SYNOPSIS

    use CFX5::Config::Environment;
    return get_environment_variable("AWP_ROOT");

=head1 DESCRIPTION

This module provides a set of functions to get the versioned ANSYS environment 
variables .

COPYRIGHT ANSYS, ALL RIGHTS RESERVED

=cut

package CFX5::Config::Environment;

use strict;
use Carp;

use CFX5::Config qw(%Config export_conf append_to_libpath prepend_to_libpath
                    append_to_execpath prepend_to_execpath);

use Exporter;
use vars     qw(@ISA @EXPORT_OK %EXPORT_TAGS);
@ISA       = qw(Exporter);
@EXPORT_OK = qw( get_environment_variable );

%EXPORT_TAGS = (
    'all' => [ qw( get_environment_variable ) ]
);

=head2 get_environment_variable
This subroutine returns the value of an ANSYS installation environment 
variable. It recieves a string and appends to it the Base Release version.

Parameters:
    $env_string: The base, unversioned, name of the environment string.
=cut
sub get_environment_variable {
    my $env_string = shift;
    my $version    = $Config{CFXBASERELEASE};

    # Environment variables set by the ANSYS installer follow the pattern of:
    # "$STRING$BASERELEASE", e.g. AWP_LOCALE160.
    my $envvar= $env_string.$version;
    
    return $ENV{$envvar} if defined $ENV{$envvar};
    undef;
}

1;