Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Array indirection



* Wojciech Pietron [2006.10.03 12:00]:
> ==================================================
> #!/bin/zsh
> 
> names=(peter ann)
> digits=(one two three four)
> analyze=(names digits)
> 
> for t in $analyze; do
>     for ((i=1; i<=${(P)#t}; i++)); do
>         #No problems with displaying the indirect tables
>         echo ${(P)t}
>     done
> done
> ==================================================
> 
> I have no problems with displaying the contents of the indirect table
> inside of the inner loop but how can I do the following operations there:
> - displaying i-th element of the array;

print -r -- "${(P)${t}[$i]}"

> - setting i-th element of the array.

eval "${t}[$i]=foobar"

HTH,

-- 
JR



Messages sorted by: Reverse Date, Date, Thread, Author