#!/bin/bash APPNAME="AnyApp" screen=1 if [! screen ]; then { cat > /tmp/new_prog_file << EOF } else { cat << EOF } print "This is the var \$APPNAME and this is what needs to get substituted $APPNAME\n"; EOF #### #!/usr/bin/perl $APPNAME="AnyApp" require "prog_file.lib"; read_prog #### sub read_prog print <<"EOF"; print "This is the var \$APPNAME and this is what needs to get substituted $APPNAME\n"; EOF 1;