in reply to EXPORT variables

Note that you can't modify your caller's environment variables directly. If you write this in perl:
$ENV{PATH} = "/home/abc/xyz/bin:$ENV{PATH}";

It will only affect programs you call from that perl script.

The standard way of altering your caller's environment is to emit shell code, and evaluate that:

# my_env.pl #!/usr/bin/perl print q{export PATH=/home/abc/xyz/bin:$PATH}, "\n"; # and this is how you call it: $ eval `./my_env.pl`

Replies are listed 'Best First'.
Re^2: EXPORT variables
by sonalig (Acolyte) on Jun 09, 2008 at 23:30 UTC
    Hey, Thanks everyone. U all saved my day. I am now able to run my script. I have one more question: Is there a way in which we can run cp, mv commands etc that run from bash to be executed within a perl script?