help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dumping a hash table


From: Mark Burgess
Subject: Re: Dumping a hash table
Date: Wed, 9 Mar 2005 20:49:57 +0100
User-agent: Internet Messaging Program (IMP) 3.2.2

Alas, this problem is not solvable at present. The solution will be in
cfengine 3. It requires a different structure with a lot of reorganization.

sorry

Mark

Quoting Chip Seraphine <chip@trdlnk.com>:

> I've learned, to my delight, that I can conditionally add more key-val 
> pairs into an associative array:
> 
> control:
>     hashtable=   ( A("key1","value1") A("key2","value2") )
> 
>     solaris::
>        hashtable= ( A ("solaris_specific_thingie","value3") )
> 
> 
> Great!  The problem comes when it is time to extract these values.  What 
> I desperately need is something
> that expands to all the keys in the associative array, but I can't find 
> such an animal.  Any ideas?
> 
> Here's what I am currently doing:
> 
> shellcommands:
>     !solaris::
>         "/some/script/that/uses/classes/as/args.sh  $(hashtable[key1]) 
> $(hashtable[key2])"
>     solaris::
>             "/some/script/that/uses/classes/as/args.sh  \
>               $(hashtable[key1]) $(hashtable[key2]) 
> $(hashtable[solaris_specific_thingie])"
> 
> 
> Obviously, this is not a good way to go; there is a lot of repeat 
> typing, and any time I add a key I have to add it to the output section 
> as well.  Here's what I would like to do:
> 
> 
> shellcommands:
>     any::
>        "/some/script/that/uses/classes/as/args.sh $(hashtable[*])"
> 
> ....where $(hashtable[*]) expands to everything in the hashtable.  I'd 
> be happy with just about any syntactic device that did not require me to 
> track all of my keys.
> 
> I've also tried keep track of keys in a list variable, but I couldn't 
> get the iteration to work when the iterated variable is inside the 
> associative [brackets].
> 
> Has anyone come up with a clever way around this problem?
>       
> 
> 
> -- 
> 
> Chip Seraphine
> Unix Administrator
> TradeLink, LLC
> 312-264-2048
> chip@trdlnk.com
> 
> 
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-cfengine
> 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  Mark.Burgess@iu.hio.no
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]