how do I access ksh environment array variables in perl?

A

Andy Haupt

hello,

in ksh you can set array variables like
a[1]=x
a[4]=y
and access them like
echo ${a[1]}

how do I access this array in Perl?

$ENV{"a"} retrieves 'x' (the value of a[1])
keys %ENV lists 'a' amongst its vars

but how do I
find out that a is an array, the length of a and its
subscripts and values?


rgds
andy
 
C

Chris Mattern

Andy said:
hello,

in ksh you can set array variables like
a[1]=x
a[4]=y
and access them like
echo ${a[1]}

how do I access this array in Perl?

You don't. Array variables are Korn Shell specific;
they can only be set and accessed from the Korn shell.
If you leave ksh, the only thing accessible is the
first element of the array under the name of the array.
$ENV{"a"} retrieves 'x' (the value of a[1])
keys %ENV lists 'a' amongst its vars

Correct. You have access to the first element of the
array, which gets listed under the name of the array.
but how do I
find out that a is an array, the length of a and its
subscripts and values?

You don't, because you can't. Once you leave the
Korn Shell, you lose all your arrays. Perl doesn't
inherit them.
rgds
andy

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top