| Eric J. Roode on Sat, 26 Jul 2003 13:58:34 -0400 |
|
On Sat, Jul 26, 2003 at 08:12:42AM -0700, James wrote:
> I am looking for a way to use variable substitution
> with environment variables. My /etc/environment looks
> like this:
>
> NUM_X=6
> X1="some value"
> X2="some value"
> X3="some value"
> X4="some value"
> X5="some value"
> X6="some value"
>
>
> Trying to keep things dynamic, I would like to print
> out all values of X(n) by using a 'for' statement,
> which goes like this:
>
> $num = $ENV{'NUM_X'};
>
> for ($i = 1; $i <= $num; $i++) {
> printf ("%15s\n", $ENV{'X[$i]'});
> }
printf ("%15s\n", $ENV{"X$i"});
You were close. :-)
--
Eric J. Roode sdn@comcast.net
$_ = reverse sort $/.r , qw p ekca ts lre reh
uJ p, map $_ . $" , qw e p h tona e and print
Attachment:
pgpXG8M1oByqQ.pgp
|
|