#!/usr/bin/bash # Create a temporary shell script using perl perl_program.pl > /tmp/setenv.$$ # source the temporary script and then remove it . /tmp/setenv.$$ rm -f /tmp/setenv.$$ # run another program with the modified environment another_program