- %ENV
-
The hash
%ENV
contains your current environment. Setting a value inENV
changes the environment for any child processes you subsequentlyfork()
off.ハッシュ
%ENV
には、その時点の環境変数が設定されています。ENV
に値を設定することで、 以後にfork()
した子プロセスの環境変数を変更します。As of v5.18.0, both keys and values stored in
%ENV
are stringified.v5.18.0 から、
%ENV
に補完されたキーと値の両方は文字列化されます。my $foo = 1;
$ENV{'bar'} = \$foo;
if( ref $ENV{'bar'} ) {
say "Pre 5.18.0 Behaviour";
} else {
say "Post 5.18.0 Behaviour";
}Previously, only child processes received stringified values:
以前は、子プロセスのみが文字列化された値を受け取っていました:
my $foo = 1;
$ENV{'bar'} = \$foo;
# Always printed 'non ref'
system($^X, '-e',
q/print ( ref $ENV{'bar'} ? 'ref' : 'non ref' ) /);This happens because you can't really share arbitrary data structures with foreign processes.
これは、外部プロセスと本当に任意のデータ構造を共有することができないために 起きます。