help-cfengine
[Top][All Lists]
Advanced

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

Dumping a hash table


From: Chip Seraphine
Subject: Dumping a hash table
Date: Wed, 09 Mar 2005 13:39:00 -0600
User-agent: Mozilla Thunderbird 1.0 (X11/20041208)

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





reply via email to

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