in reply to Command line works

I am guessing from the name and the way you run it from the command line that setup-env is a script that sets environment variables. When you run it from your perl script, a new process will be started to run a shell to interpret your script. The environment variables will be set in this shell which will then exit. No environment variables will be set in your perl process.

If you want the environment variables set in your perl process, you can either run setup-env before starting perl or within your perl program you can set environemnt variables using %ENV.