cc: [email protected]
Subject: Re: [ast-users] ksh93 array of hashes and a hash of hashes and one  
question
--------

> # So I use the following code to store the items I want into a compound 
> variable:
> str=$(uname -a)
> typeset -C uname                        # declare a compound variable
> uname.os=${str:0:5}                     # ${str:start:length} is substr 
> ( perl speaking )
> uname.virtualMachine=${str:6:16}
> uname.linuxKernel=${str:23:16}
> uname.osName=${str:40:10}
> uname.date=${str:55:27}
> uname.arch=${str:84:5}
> uname.end=${str:104:9}
> 
> # trying , in a loop to get at the values :
> 
> for i in ${!uname.*}
> do
>          print $i '->' ${i}  VALUE??
> 
> done
> 
> output of the script :
> uname.arch -> uname.arch VALUE??
> uname.date -> uname.date VALUE??
> uname.end -> uname.end VALUE??
> uname.linuxKernel -> uname.linuxKernel VALUE??
> uname.os -> uname.os VALUE??
> uname.osName -> uname.osName VALUE??
> uname.virtualMachine -> uname.virtualMachine VALUE??
> 
> I do not get back the value of the compound variable : What am I doing 
> wrong ???
> 
> kind regards Arno Teunisse
> 

$i and ${i} mean the same thing.  The {} are optional for identifiers
that are not followed by alphnumeric, [ or . .

You what to get the value of $i,
        eval \${$i}
It would be better to create a reference to the variable
        nameref r=$i
then $r would be the value of $i and ${!r} would be i.

Associative arrays are different in that the subscripts
are evaluated to determine the variable.

David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to