On 2003-01-03 at 15:24 -0200, Carlos Carvalho wrote: > Phil Pennock (Phil.Pennock@globnix.org) wrote on 3 January 2003 16:45: > >% bar='Fred Bloggs' > >% foo='bar' > >% function escr { print ${(P)foo} } > >% escr > >Fred Bloggs > > > >Is the above sufficient? > > Unfortunately no, because I don't need it only for printing, but for > referencing as well. I have an array and I'd like to access the > elements by more meaningful names, so I tried to do > > % alias -g guess_what='array[1]', etc. > > Your suggestion doesn't work however when an assignment has to be made > to guess_what. > > >You might wish to read zshexpn(1), since there are many other weird and > >wonderful ways in which zsh can pervert your data on demand. > > I did but didn't see this possibility. In fact I still don't see... > What's the relation between recognizing the same escape sequences as > print and making a substitution? I'd be grateful for an explanation. print is merely what was used for showing the results. The variable substitution does not rely upon print. % set -A array alpha beta gamma delta epsilon zeta % guess_what='array[3]' % echo ${(P)guess_what} gamma % guess_what='array[4]' % echo ${(P)guess_what} delta % guess_what='array[1]' % for i in $(perl -le "print foreach split //, '${(P)guess_what}'") ; echo $i a l p h a % My suggestion appears to work, independent of echo/print. :^) I think that you're confusing "print -P", which recognises the same escape sequences as are used in prompt substitution, with the parameter expansion flag 'P', which is described in zshexpn(1). -- "We've got a patent on the conquering of a country through the use of force. We believe in world peace through extortionate license fees." -- Andy Forster