From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13203 invoked from network); 21 Oct 2004 11:06:29 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Oct 2004 11:06:29 -0000 Received: (qmail 71575 invoked from network); 21 Oct 2004 11:06:21 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Oct 2004 11:06:21 -0000 Received: (qmail 27857 invoked by alias); 21 Oct 2004 11:06:10 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8085 Received: (qmail 27843 invoked from network); 21 Oct 2004 11:06:09 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 21 Oct 2004 11:06:09 -0000 Received: (qmail 70454 invoked from network); 21 Oct 2004 11:05:39 -0000 Received: from mail1.messagelabs.com (212.125.75.4) by a.mx.sunsite.dk with SMTP; 21 Oct 2004 11:05:37 -0000 X-VirusChecked: Checked X-Env-Sender: Stephane.Chazelas@morse.com X-Msg-Ref: server-23.tower-1.messagelabs.com!1098356732!22304046!1 X-StarScan-Version: 5.4.2; banners=-,-,- X-Originating-IP: [195.152.231.104] Received: (qmail 4836 invoked from network); 21 Oct 2004 11:05:32 -0000 Received: from unknown (HELO GIS-MAIL-01.morse.corp.wan) (195.152.231.104) by server-23.tower-1.messagelabs.com with SMTP; 21 Oct 2004 11:05:32 -0000 Received: from frhdtmp102861 (frhdtmp102861.morse.corp.wan [10.25.10.16]) by GIS-MAIL-01.morse.corp.wan with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id VCVN164Z; Thu, 21 Oct 2004 12:05:32 +0100 Date: Thu, 21 Oct 2004 12:05:28 +0100 From: Stephane Chazelas To: zsh-users@sunsite.dk Subject: Re: Associative Arrays Message-ID: <20041021110526.GE1740@frhdtmp102861.morse.corp.wan> Mail-Followup-To: zsh-users@sunsite.dk References: <20041020195348.GJ11322@puritan.pcp.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20041020195348.GJ11322@puritan.pcp.ath.cx> User-Agent: Mutt/1.5.6i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 On Wed, Oct 20, 2004 at 09:53:48PM +0200, Nikolai Weibull wrote: > I'm have a few questions regarding associative arrays. What exactly is > the A flag for parameter expansion for? I mean, how does one use it, > and how does one use the AA flag? Not very useful, except maybe to avoid the use of typeset. typeset -A a a=(foo bar) can be written: : ${(AA)=a::=foo bar} > Is there any way to pass an associative array as ONE argument to a > function and easily deal with it as the same associative array in the > other function? The easiest way seems to be the "pass-by-reference" > technique, where one simply passes the name of the array and then use > the P flag to deal with it. > nikolai You could use "${${(@qqkv)A}[*]}" $ typeset -A A $ A=("foo" "b bar" \' \" "" q) $ print -lr "${${(@qqkv)A}[*]}" '' 'q' 'foo' 'b bar' ''\''' '"' So that in the function you can have typeset -A local_hash eval "local_hash=($1)" or: typeset -A local_hash local_hash=("${(Q@)${(z)1}}") -- Stephane