Date: Mon, 13 Apr 1998 00:10:31 -0500 (CDT) From: Bruce Albrecht <bruce@zuhause.mn.org> To: Leonard <leonardc9@usa.net> Cc: questions@FreeBSD.ORG Subject: Re: Setting shell environment vars in perl Message-ID: <199804130510.AAA14499@zuhause.mn.org> In-Reply-To: <3.0.5.32.19980412125035.007b7e30@pop.slip.net> References: <3.0.5.32.19980412125035.007b7e30@pop.slip.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Leonard writes: > I'm new to perl and was wondering if anybody could give me some > pointers on how to set a shell environmental variable, specifically > HOME, using perl. I've tried: > > $ENV{'HOME'} = /foo > > but it doesn't seem to work, leading me to suspect that perhaps $ENV > is read-only. > > If anybody could point me in the right direction, I'd really > appreciate it. Setting environmental variables in perl scripts do not change the environment variables in the shell that invoked it, but any children of the perl script (i.e., something that uses fork, system, exec, backticks, pipes in open statements) will have the environment variables you set in the script. This is not a perl limitation, it's the way environment variables work on all Unix operating systems. The closest you can get to having a perl script set environment variables for your shell would be to do something like eval `perlscript` and have perlscript output something like VAR=value; export VAR (bourne, bash, ksh) or setenv VAR value (csh, tcsh) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804130510.AAA14499>