rc> what the following sentence in a perl do? Please explain with detail.
rc> grep (do { chop; s/^([^=]+)=(.*)$/$ENV{$1}=$2/e},`. /etc/Tivoli/setup_env.sh;env`);
1) `. /etc/Tivoli/setup_env.sh;env`
source that .sh file and print the environment
2) s/^([^=]+)=(.*)$/$ENV{$1}=$2/e
take all the environment variables from (1) and put them into the
current environment (using grep for side effects, which is naughty)
So basically it's an unnecessarily complex way to grab the environment
resulting from /etc/Tivoli/setup_env.sh
While I would have written that as:
for (`. /etc/Tivoli/setup_env.sh; env`) {
$ENV{$1} = $2 if (/^([^=]+)=(.*)$/);
}
that's not less complex, just more readable (IMHO). Can you think of a
less complex way to do that? (assuming that /etc/Tivoli/setup_env.sh may
contain non-trivial /bin/sh code)