This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pod/perlvar.pod: Document changes to %ENV
authorKent Fredric <kentnl@cpan.org>
Sat, 15 Dec 2012 10:21:29 +0000 (23:21 +1300)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 13 Jul 2013 07:45:13 +0000 (00:45 -0700)
Including Historical context, and relevance to IPC.

reformatted with Jim Keenans Suggestions

pod/perlvar.pod

index 4bbfba2..add3756 100644 (file)
@@ -410,6 +410,27 @@ The hash C<%ENV> contains your current environment.  Setting a
 value in C<ENV> changes the environment for any child processes
 you subsequently C<fork()> off.
 
+As of 5.17.3, both keys and values stored in C<%ENV> are stringified.
+
+    my $foo = 1;
+    $ENV{'bar'} = \$foo;
+    if( ref $ENV{'bar'} ) {
+        say "Pre 5.17.3 Behaviour";
+    } else {
+        say "Post 5.17.3 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.
+
 =item $SYSTEM_FD_MAX
 
 =item $^F