Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > how do I access ksh environment array variables in perl?

Reply
Thread Tools

how do I access ksh environment array variables in perl?

 
 
Andy Haupt
Guest
Posts: n/a
 
      03-24-2005
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
 
Reply With Quote
 
 
 
 
Chris Mattern
Guest
Posts: n/a
 
      03-24-2005
Andy Haupt wrote:

> 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?"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
ruby and ksh ClassRubyExceptionHandline Ruby 4 09-09-2006 01:37 PM
calling ksh script from python ronan_boisard@yahoo.com Python 12 06-08-2005 09:07 AM
passing string to ksh with system command joez3@yahoo.com Perl Misc 4 12-10-2004 06:14 AM
program to copy files - problems - unix ksh to java kaeli Java 8 02-13-2004 08:59 AM



Advertisments