From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4160 invoked from network); 27 May 2006 22:11:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.2 (2006-05-25) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.2 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 27 May 2006 22:11:09 -0000 Received: (qmail 5491 invoked from network); 27 May 2006 22:11:03 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 27 May 2006 22:11:03 -0000 Received: (qmail 16780 invoked by alias); 27 May 2006 22:10:50 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10318 Received: (qmail 16771 invoked from network); 27 May 2006 22:10:49 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 27 May 2006 22:10:49 -0000 Received: (qmail 3845 invoked from network); 27 May 2006 22:10:48 -0000 Received: from vms048pub.verizon.net (206.46.252.48) by a.mx.sunsite.dk with SMTP; 27 May 2006 22:10:47 -0000 Received: from torch.brasslantern.com ([71.116.105.50]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0IZY00INT2XX1YK2@vms048.mailsrvcs.net> for zsh-users@sunsite.dk; Sat, 27 May 2006 17:10:46 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id k4RMAi7R025450 for ; Sat, 27 May 2006 15:10:45 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id k4RMAi98025449 for zsh-users@sunsite.dk; Sat, 27 May 2006 15:10:44 -0700 Date: Sat, 27 May 2006 15:10:44 -0700 From: Bart Schaefer Subject: Re: Keying arrays to names: is there an array of arrays? In-reply-to: To: zsh-users@sunsite.dk Message-id: <060527151044.ZM25448@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <44771E3E.9070102@ulpmm.u-strasbg.fr> <200605261540.k4QFeReG007573@news01.csr.com> Comments: In reply to "Johann 'Myrkraverk' Oskarsson" "Re: Keying arrays to names: is there an array of arrays?" (May 27, 7:09pm) On May 27, 7:09pm, Johann 'Myrkraverk' Oskarsson wrote: } } > This reminds me I was going to post a general solution along the same } > lines which deals with embeded spaces etc.: } } Is it possible to abstract that trick into functions? That is, so the } function takes the array name, key, and value as arguments? I'll assume you mean the *associative* array (hash) name. A function to do the assignment isn't too terrible, though there are scoping issues -- either the hash already has to exist, or you can only create it in the global scope by using typeset -g: setbykey() { local h=$1 k=$2 shift 2 set -- ${(q)*} typeset -gA $h typeset -g $h\[$k\]="$*" } A function to read back the value is a bit trickier. What do you want to do with the array once you have it? A common fallback would be to stuff it in $reply: getbykey() { set -- $1\[$2\] reply=( ${(Q)${(z)${(P)1}}} ) } typeset -A hash setbykey hash key one 'two three' '"four five six"' getbykey hash key print -rl $reply Incidentally: } I classify Outlook mail as spam, use something else. Someone asking for assistance has no right to dictate terms. You want my help, you take it the way I send it. I don't happen to use Outlook, but next time I see something like this, I just won't answer.