.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Env::Sanctify 3pm" .TH Env::Sanctify 3pm "2022-10-13" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Env::Sanctify \- Lexically scoped sanctification of %ENV .SH "VERSION" .IX Header "VERSION" version 1.12 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& my $sanctify = Env::Sanctify\->sanctify( sanctify => [ \*(Aq^POE\*(Aq ] ); \& \& # do some stuff, fork some processes etc. \& \& $sanctify\->restore \& \& { \& \& my $sanctify = Env::Sanctify\->sanctify( env => { POE_TRACE_DEFAULT => 1 } ); \& \& # do some stuff, fork some processes etc. \& } \& \& # out of scope, %ENV is back to normal .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Env::Sanctify is a module that provides lexically scoped manipulation and sanctification of \&\f(CW%ENV\fR. .PP You can specify that it alter or add additional environment variables or remove existing ones according to a list of matching regexen. .PP You can then either \f(CW\*(C`restore\*(C'\fR the environment back manually or let the object fall out of scope, which automagically restores. .PP Useful for manipulating the environment that forked processes and sub-processes will inherit. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .ie n .IP """sanctify""" 4 .el .IP "\f(CWsanctify\fR" 4 .IX Item "sanctify" Creates an Env::Sanctify object. Takes two optional arguments: .Sp .Vb 2 \& \*(Aqenv\*(Aq, a hashref of env vars to add to %ENV; \& \*(Aqsanctify\*(Aq, an arrayref of regex pattern strings to match against current %ENV vars; .Ve .Sp Any \f(CW%ENV\fR var that matches a \f(CW\*(C`sanctify\*(C'\fR regex is removed from the resultant \f(CW%ENV\fR. .SH "METHODs" .IX Header "METHODs" .ie n .IP """restore""" 4 .el .IP "\f(CWrestore\fR" 4 .IX Item "restore" Explicitly restore the previous \f(CW%ENV\fR. This is called automagically when the object is \f(CW\*(C`DESTROY\*(C'\fRed, for instance, when it goes out of scope. .SH "CAVEATS" .IX Header "CAVEATS" It has been reported that redefining the Env::Sanctify object causes unexpected behaviour. .PP .Vb 2 \& use strict; \& use warnings; \& \& use Env::Sanctify; \& \& $ENV{TEST} = \*(AqTest thing\*(Aq; \& \& my $sanctify = Env::Sanctify\->sanctify( sanctify => [ \*(AqTEST\*(Aq ] ); \& \& printf "My ENV{TEST}: %s\en", $ENV{TEST}; \& \& $sanctify = Env::Sanctify\->sanctify( env => { TEST => \*(AqOther answer\*(Aq } ); \& \& printf "My ENV{TEST}: %s\en", $ENV{TEST}; .Ve .PP This script outputs: .PP .Vb 2 \& My ENV{TEST}: \& My ENV{TEST}: Test thing .Ve .SH "AUTHOR" .IX Header "AUTHOR" Chris Williams .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2014 by Chris Williams. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.