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

nested parameter expansion



I can't get, what should be simple nested parameter to work.
I think that $ndx needs to be expanded before the letter P before it 1st.

Simple example:

    ndx=1
    P1_ARRAY=("1" "2" "3")
    
    print ${P${ndx}_ARRAY}
#results in: "zsh bad substitution

    print ${~P${ndx}_ARRAY}
#results in: "zsh bad substitution

    print ${(P)P${ndx}_ARRAY}
#results in: "zsh bad substitution

I want to do a simple 'for' loop like this:

  for ndx in ("1" "2" "3")		# for multiple arrays not defined in this simple example.
      do
      for element in ${P${ndx}_ARRAY}
        do
	print "Process element."
	done
     done


Any assistance would be appreciated







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