Right. If you wanted to do it all in one script, something like the following would probably be the cleanest (untested):
# get the "output" environment from the script into a hash
my %envhash = map { chomp; split( /=/, $_, 2 ) } `bash.script`;
# now get the "ambient environment" and delete that from the hash:
for ( `bash -c env` ) {
( my $var, undef ) = split( /=/ );
delete $envhash{$var};
}
|