in reply to set environment for parent process

The problem you're running into is that environment variables that are set only apply to the process where they're set and any subprocesses. In this case, system creates a child process, the environment variables are set in that child process, then the child process exits. In the shell scripts, they're included with the "dot" operator or "source" command, which runs those scripts as if they were a part of the current script.

Unfortunately there's no similarly easy mechanism in Perl, because the scripts are written in the shell scripting language, Perl doesn't include an interpreter for that language. Instead, you have to parse them yourself, as the example linked to above does; essentially it implements a very small and simplistic shell interpreter for the small subset of the shell language you're interested in (setting environment variables).