From owner-freebsd-arch Mon Jul 22 18:40:40 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F0ED937B400 for ; Mon, 22 Jul 2002 18:40:36 -0700 (PDT) Received: from thuvia.demon.co.uk (thuvia.demon.co.uk [193.237.34.248]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4834743E31 for ; Mon, 22 Jul 2002 18:40:35 -0700 (PDT) (envelope-from mark@thuvia.demon.co.uk) Received: from dotar.thuvia.org (dotar.thuvia.org [10.0.0.4]) by phaidor.thuvia.org (8.11.6/8.11.6) with ESMTP id g6N1e4b87365; Tue, 23 Jul 2002 02:40:05 +0100 (BST) (envelope-from mark@thuvia.demon.co.uk) Received: from dotar.thuvia.org (localhost [IPv6:::1]) by dotar.thuvia.org (8.12.3/8.12.3) with ESMTP id g6N1e4KC034105; Tue, 23 Jul 2002 02:40:04 +0100 (BST) (envelope-from mark@dotar.thuvia.org) Received: (from mark@localhost) by dotar.thuvia.org (8.12.3/8.12.3/Submit) id g6N1e3ZC034104; Tue, 23 Jul 2002 02:40:03 +0100 (BST) Date: Tue, 23 Jul 2002 02:40:03 +0100 (BST) From: Mark Valentine Message-Id: <200207230140.g6N1e3ZC034104@dotar.thuvia.org> In-Reply-To: <71AEEE0E-9DD3-11D6-A01D-000393038CC8@queasyweasel.com> X-Mailer: Mail User's Shell (7.2.6 beta(5) 10/07/98) To: "Jordan K. Hubbard" , Andrew Reilly Subject: Re: Package system flaws? Cc: jos@catnook.com, freebsd-arch@FreeBSD.ORG Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > From: "Jordan K. Hubbard" > Date: Mon 22 Jul, 2002 > Subject: Re: Package system flaws? > sh(1) is already notorious for its weak > variable handling (no associative arrays), But hey, it has "eval"... ;-) main() { array_init colour array_set colour apple red array_set colour pear green for_each colour c 'echo "The $c is `array_get colour $c`."' } array_init() { array=$1 eval _keys_$array= } array_set() { array=$1 key=$2 value=$3 eval _elements_${array}_${key}="$value" eval _keys_${array}=\"\$_keys_${array} $key\" } array_get() { array=$1 key=$2 eval value=\$_elements_${array}_${key} echo "$value" } for_each() { array=$1 variable=$2 procedure=$3 eval for key in \$_keys_${array}\; do \{ $variable=\$key\; $procedure\; \}\; done } main Almost as readable as Tcl, I'd say. And as for Perl... Cheers, Mark. -- Mark Valentine, Thuvia Labs "Tigers will do ANYTHING for a tuna fish sandwich." Mark Valentine uses "We're kind of stupid that way." *munch* *munch* and endorses FreeBSD -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message