When you write \%ENV you get a "live" reference to the hash %ENV. Any further changes to %ENV will be reflected in \%ENV.

Example:

$ENV{FOO} = 1; my $ref = \%ENV; # Change something in %ENV $ENV{FOO} = 2; print $ref->{FOO}, "\n"; # prints 2.

If you actually need to check other scripts changing %ENV, you're out of luck. That's not how Unix environment variables work. Each process gets its own copy of the environment, cloned from its parent process. Any changes it makes to its environment cannot be seen by its parent process, nor its sibling processes. Its child processes will of course see the changes in their own cloned copies of the environment, but they cannot pass back any of their own changes.

If you actually need to communicate changes to %ENV between processes, then you need to look into interprocess communication (IPC). This is usually accomplished by reading from and writing to Unix sockets (which are essentially filehandles used for communication between processes on the same machine) or TCP sockets (which are Unix sockets generalized to work over the Internet).

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

In reply to Re^3: Can I share instance through Moose::Role ? by tobyink
in thread Can I share instance through Moose::Role ? by dd1942

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.