1Env::Sanctify(3)      User Contributed Perl Documentation     Env::Sanctify(3)
2
3
4

NAME

6       Env::Sanctify - Lexically scoped sanctification of %ENV
7

VERSION

9       version 1.12
10

SYNOPSIS

12         my $sanctify = Env::Sanctify->sanctify( sanctify => [ '^POE' ] );
13
14         # do some stuff, fork some processes etc.
15
16         $sanctify->restore
17
18         {
19
20           my $sanctify = Env::Sanctify->sanctify( env => { POE_TRACE_DEFAULT => 1 } );
21
22           # do some stuff, fork some processes etc.
23         }
24
25         # out of scope, %ENV is back to normal
26

DESCRIPTION

28       Env::Sanctify is a module that provides lexically scoped manipulation
29       and sanctification of %ENV.
30
31       You can specify that it alter or add additional environment variables
32       or remove existing ones according to a list of matching regexen.
33
34       You can then either "restore" the environment back manually or let the
35       object fall out of scope, which automagically restores.
36
37       Useful for manipulating the environment that forked processes and sub-
38       processes will inherit.
39

CONSTRUCTOR

41       "sanctify"
42           Creates an Env::Sanctify object. Takes two optional arguments:
43
44             'env', a hashref of env vars to add to %ENV;
45             'sanctify', an arrayref of regex pattern strings to match against current %ENV vars;
46
47           Any %ENV var that matches a "sanctify" regex is removed from the
48           resultant %ENV.
49

METHODs

51       "restore"
52           Explicitly restore the previous %ENV. This is called automagically
53           when the object is "DESTROY"ed, for instance, when it goes out of
54           scope.
55

CAVEATS

57       It has been reported that redefining the Env::Sanctify object causes
58       unexpected behaviour.
59
60         use strict;
61         use warnings;
62
63         use Env::Sanctify;
64
65         $ENV{TEST} = 'Test thing';
66
67         my $sanctify = Env::Sanctify->sanctify( sanctify => [ 'TEST' ] );
68
69         printf "My ENV{TEST}: %s\n", $ENV{TEST};
70
71         $sanctify = Env::Sanctify->sanctify( env => { TEST => 'Other answer' } );
72
73         printf "My ENV{TEST}: %s\n", $ENV{TEST};
74
75       This script outputs:
76
77         My ENV{TEST}:
78         My ENV{TEST}: Test thing
79

AUTHOR

81       Chris Williams <chris@bingosnet.co.uk>
82
84       This software is copyright (c) 2014 by Chris Williams.
85
86       This is free software; you can redistribute it and/or modify it under
87       the same terms as the Perl 5 programming language system itself.
88
89
90
91perl v5.38.0                      2023-07-20                  Env::Sanctify(3)
Impressum