setenv - conveniently (re)set %ENV variables at compile time


setenv documentation Contained in the setenv distribution.

Index


Code Index:

NAME

Top

setenv - conveniently (re)set %ENV variables at compile time

SYNOPSIS

Top

 no setenv;                # BEGIN { %ENV = () }

 no setenv qw( FOO BAR );  # BEGIN { delete @ENV{ qw( FOO BAR ) } }

 use setenv                # BEGIN { $ENV{FOO} = 1, $ENV{BAR} = 2 }
   FOO => 1,
   BAR => 2,
 ;

DESCRIPTION

Top

Provide a simple way to (re)set %ENV variables at compile time. Usually used during debugging only. This is just syntactic sugar, without any additives.

VERSION

Top

This documentation describes version 0.03.

METHODS

Top

There are no methods.

THEORY OF OPERATION

Top

Since "import" and "noimport" are called by Perl at compile time when doing a use or no, it will perform any (re)setting of %ENV at that time.

REQUIRED MODULES

Top

 (none)

AUTHOR

Top

 Elizabeth Mattijsen

COPYRIGHT

Top


setenv documentation Contained in the setenv distribution.

package setenv;

# where are we?
$VERSION = '0.03';

# be as strict and verbose as possible
use strict;
use warnings;

# satisfy -require-
1;

#---------------------------------------------------------------------------
#
# Standard Perl functionality
#
#---------------------------------------------------------------------------
# import
#
#  IN: 1 class (ignored)
#      2..N hash with key / value pairs to set in %ENV

sub import {
    shift;

    # set the keys / values
    while ( my ( $key, $value ) = splice @_, 0, 2 ) {
        $ENV{$key} = $value;
    }

    return;
}    #import

#---------------------------------------------------------------------------
# unimport
#
#  IN: 1 class (ignored)
#      2..N environment variables to remove (default: all)

sub unimport {
    shift;

    # get rid of just these, please
    if (@_) {
        delete @ENV{@_};
    }

    # get rid of all
    else {
        %ENV = ();
    }

    return;
}    #unimport

#---------------------------------------------------------------------------

__END__