in reply to source a file in Linux using perl script

Your execution environment inherits the environment set up via ~/.bash_profile. I recommend you not try to source that file in the script. If you need to access the environment and manipulate it, you do so via %ENV. Then anything you run under that perl process will inherit this environment. A child process can't affect the parent process's (e.g., bash shell) environment once the process is complete. In other words, you can't use a script or program to update the environment of the shell in a persistent way (after the perl script has exited).

If you wish to make CTC_HOME available as part of the environment in your script you can update %ENV in the code:

use strict; use warnings; local %ENV = %ENV; # NOTE: local is used here in case you wish to # restore the original %ENV in a different scope # of this script $ENV{CTC_HOME} = q{/Inf/work/}; # ... now "CTC_HOME" is available for all child # processes (via fork, system, ``, etc) of $0 (this script)

Given this idiom, you could then pass in CTC_HOME as a commandline argument or, better still, as a configuration file that you can then parse via Config::Tiny. That said, you could also just make sure the environment is set up as you wished via ~/.bash_profile before execution to avoid all of this. I am still not sure why you want to effect ~/.bash_profile. It almost seems like you're wishing to ensure an environment via command invoked via ssh. In this case, note that ssh has options that allow you to pass remote environmental viariables via the ssh command itself.