[H-GEN] Reading from and writing to, environment variable from PERL

Bruce Campbell bc at humbug.org.au
Wed Sep 10 03:11:51 EDT 2003


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

On Wed, 10 Sep 2003, Cunningham, Conor wrote:

> A couple of questions if I may.
>
> 1. How can I access the environment/local variable?

'man perlvar' first, and then use '$ENV{data_period}'.  Remember that its
effectively read-only as far as passing data back to the invoking shell
goes.

> 2. Secondly, the PERL script is going to be called from a KSH script. By
> using a RETURN function, or something similar within my PERL script, is
> it possible to do something like this.

In your sh script, you probably want:

	date_period="2003-09-09"	# define a variable.
	export date_period		# put the variable in the environment
	string=`date_format.pl y-m`	# date_format.pl prints the output

--==--
Bruce.

Of course, most system's supplied 'date' command will also return:

	string=`date +%Y-%m --date "2003-09-09"`



--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list