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
|