I have a shell script, with a list of shell variables, which is executed before entering a programming environment.
I want to use a Perl script to enter the programm
But yes! It may be!
#!/usr/bin/perl -w
use strict;
my $perldumpenv='perl -MData::Dumper -e '."'".
'\$Data::Dumper::Terse=1;print Dumper(\%ENV);'."'";
eval '%ENV=('.$1.')' if `bash -c "
source environment_defaults.sh >/dev/null;
$perldumpenv"`
=~ /^\s*\{(.*)\}\s*$/mxs;
system("obe");
A little overkill as this runs a fork to a Perl-only-to-dump environment, but running Perl bind environment in a safe manner and Data::Dumper is the library to use for sending/storing and retrieving Perl variables.
Nota: This don't care about security considerations: you have to trust environment_defaults.sh at same level as the main Perl script!!!