Maybe I'm touching some deep voodoo here, but how does one replace the version of %ENV that is used for child processes ? It seems like %ENV is just an ordinary hash, only with 'magic' scope, but the copy for forked processes isn't exactly what I expected :((

To put my question directly: how is %ENV copied by child processes ?

Some evil test code:
#!/usr/bin/perl package Env::Tie; use strict; use Tie::Hash; our @ISA = qw/Tie::StdHash/; sub TIEHASH { bless $_[1] , $_[0] } sub FETCH { $_[0]->{$_[1]} . '---BWUBUBWU' } # The '---BWUBUBWU' of course being # dynamic generated content package Test; use strict; sub print { print 'env home =', $ENV{HOME}, "\n" } package main; use strict; print "Hic sunt leones\n"; print 'env home =', $ENV{HOME}, "\n"; print "lets go\n"; my %self = %ENV; tie %ENV, 'Env::Tie', \%self; print "tied ENV\n"; print 'env home =', $ENV{HOME}, "\n"; print "lets try it in an other package\n"; Test::print(); print "lets fork perl\n"; system( 'perl', '-e', q{print 'env home =', $ENV{HOME}, "\n"} ); print "lets fork bash\n"; system( 'bash', '-c', q{echo $HOME} ); print "done\n";
The behaviour I'm looking for is that the forked processes use my modified ENV.

--
Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
>>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<

In reply to How is %ENV copied by child processes ? by Pardus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.