bannaN has asked for the
wisdom of the Perl Monks concerning the following question:

Hi,
I would like to create a perlscript that executes a DB2 ddl file for initializing a database.

But the problem is that in order to do so (Script is runned by root) i have to do a source command.

source /home/db2inst1/sqllib/db2profile
How can i execute this inside a script, and make the script inherit this environment, so that commands later in the script issued with system will inherit this env?

If i try to run something like this, the db2 command will not be recognized.
Error:
"Can't exec "db2": No such file or directory"

So if i understood you correctly that doesnt work for some reason. As you may have understood i am not that into the logic of how different shells acquire their environment, and pass it on.
Am i right in the assumption that the system command will fork and inherit the environment from the perl script?
If i am, the question still stands, how can i make the perl script acquire the db2 environment

You can however set the environment within the Perl script and then the system call will inherit it or you could run the db2profile scipt prior to running the Perl script and then everything would inherit it.