How do I export Envrionment variable to Parent Shell by calling within the perl script ?

I am trying to set parent shell title by calling export variable from the perl script using following

export PROMPT_COMMAND='echo -ne "\033]0;user authentication\007"'

Whenever I call this function from within perl script , it spawned new child process and then kill it when program execution finishes.I want set the environment(title) of Parent Terminal window from where I run the main script using perl script
I am using ubuntu with bash shell

from perlfaq8:
Q: I {changed directory, modified my environment} in a perl script. How come the change disappeared when I exited the script? How do I get my changes to be visible?

A: In the strictest sense, it can't be done--the script executes as a different process from the shell it was started from. Changes to a process are not reflected in its parent--only in any children created after the change. There is shell magic that may allow you to fake it by eval()ing the script's output in your shell; check out the comp.unix.questions FAQ for details.

******************** test1.pl
#!/usr/bin/perl
print "export ZZ=testing\n";
******************** At bash prompt
This will run test1.pl, and it's output will be as if you typed at the prompt
In this case, setting the ZZ environment variable to testing
eval `./test1.pl`

You could write the variable and or value to a file in the subshell. When it exits, the parent shell could reference the file and dot it into the environment upon exit of the subshell. If the parent shell is the interactive shell, dotting the file will have to be manual otherwise the parent shell could dot the file created by the subshell. Then simply reference the environment variable.

Example: Cut and paste the snippit into a file called test.sh and then run it: sh test.sh

#!/bin/sh
# show there is no value for variable $VAR
echo "1 from parentshell: $VAR"
(
# subshell
cat << %%% > subshell.env
VAR=VALUE
export VAR
%%%
. subshell.env
# show the variable $VAR is set
echo "2 from subshell: $VAR"
)
# show value for variable $VAR is lost from the subshell
echo "3 from parentshell: $VAR"
# add the variable $VAR to the parent environment
. subshell.env
# show that it's set
echo "4 from parentshell: $VAR"

Hi Adam ,
Thanks a lot for your help and time..After using Unset it seems to work fine. But I have small issue now.Purpose I was doing all this because I don`t want user to type anything else except ./filename. In this case, is there way I can call " eval `./xev.pl` " from within the perl script "test.pl"
I tried system() and back ticks , it didn't work for me.
My basic purpose is to put "eval `./xev`" in the beginning of my main program perl script so that I can set parent shell title to something and then execute further commands for that particular named shell

I don't know of a way.... If you make it a shell, the shell script will still run as child of your main script.

It sounds like your goal is to have a terminal window run, and have the title of the terminal window be the name of what that window is doing. If so, you might be able to start your programs like this instead:
Have ./xev be a shell script that does this (where xev.pl is your perl script):
gnome-terminal --command=./xev.pl --title='user authentication' &
This will open a new terminal window with the specified title, and will run the specified command.
There are other options, see man gnome-terminal.

Featured Post

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation.
From the Ubuntu vi…

Learn several ways to interact with files and get file information from the bash shell.
ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…