#!/usr/bin/env perl 

use strict;
use warnings;
use utf8;

my $command =
# Source the setup script to get environment variables.
# Ensure that no output is printed.
'. ./setup.sh >/dev/null 2>/dev/null;' .
# While in the environment which has the new variables,
# Use a perl command to print the environment variables as valid perl code
'perl -e \'for (keys %ENV) { print "\$ENV{\'\\\'\'", $_, "\'\\\'\'} = \'\\\'\'", $ENV{$_}, "\'\\\'\';\n"; }\'';
# Evaluate the perl code to set the variables in our own environment
eval `$command`;
# Print out the environment variables (as an example to show it works)
for (keys %ENV) {
    print $_, ' = ', "'$ENV{$_}'", "\n";
}
