Sponsored Content
Full Discussion: Associative Array
Top Forums Shell Programming and Scripting Associative Array Post 41148 by tine on Tuesday 30th of September 2003 08:56:18 AM
Old 09-30-2003
Associative Array

Hi,
I am trying to make an associative array to use in a popup_menu on a website. Here is what i have:

foreach $entr ( @entries )
{
$temp_uid[$s] = $entr->get_value(uid);
$temp_naam[$entr->get_value(uid)] = $entr->get_value(sn);
$s++;
}

This is the popup_menu i want to use it in.
popup_menu(-name=>'modcon', -values=>\@temp_uid, -labels=>\%temp_naam);

It doesn't work and i cannot find where i am wrong!
hopefully someone can help..

Tine
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl: Sorting an associative array

Hi, When using sort on an associative array: foreach $key (sort(keys(%opalfabet))){ $value = $opalfabet{$key}; $result .= $value; } How does it handle double values? It seems to me that it removes them, is that true? If so, is there a way to get... (2 Replies)
Discussion started by: tine
2 Replies

2. Shell Programming and Scripting

awk, associative array, compare files

i have a file like this < '393200103052';'H3G';'20081204' < '393200103059';'TIM';'20110111' < '393200103061';'TIM';'20060206' < '393200103064';'OPI';'20110623' > '393200103052';'HKG';'20081204' > '393200103056';'TIM';'20110111' > '393200103088';'TIM';'20060206' Now i have to generate a file... (9 Replies)
Discussion started by: shruthi123
9 Replies

3. Shell Programming and Scripting

Help needed on Associative array in awk

Hi All, I got stuck up with shell script where i use awk. The scenario which i am working on is as below. I have a file text.txt with contents COL1 COL2 COL3 COL4 1 A 500 400 1 B 500 400 1 A 500 200 2 A 290 300 2 B 290 280 3 C 100 100 I could able to sum col 3 and col4 based on... (3 Replies)
Discussion started by: imsularif
3 Replies

4. Shell Programming and Scripting

Split string into map (Associative Array)

Hi Input: { committed = 782958592; init = 805306368; max = 1051394048; used = 63456712; } Result: A map (maybe Associative Array) where I can iterate through the key/value. Something like this: for key in $map do echo key=$key value=$map done Sample output from the map: ... (2 Replies)
Discussion started by: chitech
2 Replies

5. Shell Programming and Scripting

Associative array

I have an associative array named table declare -A table table="fruit" table="veggie" table="GT" table="eminem" Now say I have a variable returning the value highway How do I find corresponding value GT ?? (this value that I find (GT in this case) is supposed to be the name of a mysql... (1 Reply)
Discussion started by: leghorn
1 Replies

6. Shell Programming and Scripting

Associative Array with more than one item per entry

Hi all I have a problem where i have a large list ( up to 1000 of items) and need to have 2 items pulled from it into variables in a bash script my list is like the following and I could have it as an array or possibly an external text file maintained separately. Every line is different and... (6 Replies)
Discussion started by: kcpoole
6 Replies

7. Shell Programming and Scripting

Morse Code with Associative Array

Continuing my quest to learn BASH, Bourne, Awk, Grep, etc. on my own through the use of a few books. I've come to an exercise that has me absolutely stumped. The specifics: 1. Using ONLY BASH scripting commands (not sed, awk, etc.), write a script to convert a string on the command line to... (22 Replies)
Discussion started by: ksmarine1980
22 Replies

8. Shell Programming and Scripting

Using associative array for comparison

Hello together, i make something wrong... I want an array that contains information to associate it for further processing. Here is something from my bash... You will know, what I'm trying to do. I have to point out in advance, that the variable $SYSOS is changing and not as static as in my... (2 Replies)
Discussion started by: Decstasy
2 Replies

9. Shell Programming and Scripting

Associative array index question

I am trying to assign indexes to an associative array in a for loop but I have to use an eval command to make it work, this doesn't seem correct I don't have to do this with regular arrays For example, the following assignment fails without the eval command: #! /bin/bash read -d "\0" -a... (19 Replies)
Discussion started by: Riker1204
19 Replies

10. UNIX for Beginners Questions & Answers

Loading associative array from exported function

Hello. I have an export of an associative array build using declare -p SOME_ARRAY_NAME > SOME_FILE_NAME.txt. Producing some thing like declare -A SOME_ARRAY_NAME=( ="some_text" ="a_text" ......... ="another_text" ) in a text file. I have a stock of functions which are sourced from... (1 Reply)
Discussion started by: jcdole
1 Replies
proplists(3erl) 					     Erlang Module Definition						   proplists(3erl)

NAME
proplists - Support functions for property lists DESCRIPTION
Property lists are ordinary lists containing entries in the form of either tuples, whose first elements are keys used for lookup and inser- tion, or atoms, which work as shorthand for tuples {Atom, true} . (Other terms are allowed in the lists, but are ignored by this module.) If there is more than one entry in a list for a certain key, the first occurrence normally overrides any later (irrespective of the arity of the tuples). Property lists are useful for representing inherited properties, such as options passed to a function where a user may specify options overriding the default settings, object properties, annotations, etc. Two keys are considered equal if they match ( =:= ). In other words, numbers are compared literally rather than by value, so that, for instance, 1 and 1.0 are different keys. EXPORTS
append_values(Key, List) -> List Types Key = term() List = [term()] Similar to get_all_values/2 , but each value is wrapped in a list unless it is already itself a list, and the resulting list of lists is concatenated. This is often useful for "incremental" options; e.g., append_values(a, [{a, [1,2]}, {b, 0}, {a, 3}, {c, -1}, {a, [4]}]) will return the list [1,2,3,4] . compact(List) -> List Types List = [term()] Minimizes the representation of all entries in the list. This is equivalent to [property(P) || P <- List] . See also: property/1 , unfold/1 . delete(Key, List) -> List Types Key = term() List = [term()] Deletes all entries associated with Key from List . expand(Expansions, List) -> List Types Key = term() Expansions = [{Property,[term()]}] Property = atom() | tuple() Expands particular properties to corresponding sets of properties (or other terms). For each pair {Property, Expansion} in Expan- sions , if E is the first entry in List with the same key as Property , and E and Property have equivalent normal forms, then E is replaced with the terms in Expansion , and any following entries with the same key are deleted from List . For example, the following expressions all return [fie, bar, baz, fum] : expand([{foo, [bar, baz]}], [fie, foo, fum]) expand([{{foo, true}, [bar, baz]}], [fie, foo, fum]) expand([{{foo, false}, [bar, baz]}], [fie, {foo, false}, fum]) However, no expansion is done in the following call: expand([{{foo, true}, [bar, baz]}], [{foo, false}, fie, foo, fum]) because {foo, false} shadows foo . Note that if the original property term is to be preserved in the result when expanded, it must be included in the expansion list. The inserted terms are not expanded recursively. If Expansions contains more than one property with the same key, only the first occurrence is used. See also: normalize/2 . get_all_values(Key, List) -> [term()] Types Key = term() List = [term()] Similar to get_value/2 , but returns the list of values for all entries {Key, Value} in List . If no such entry exists, the result is the empty list. See also: get_value/2 . get_bool(Key, List) -> bool() Types Key = term() List = [term()] Returns the value of a boolean key/value option. If lookup(Key, List) would yield {Key, true} , this function returns true ; other- wise false is returned. See also: get_value/2 , lookup/2 . get_keys(List) -> [term()] Types List = [term()] Returns an unordered list of the keys used in List , not containing duplicates. get_value(Key, List) -> term() Types Key = term() List = [term()] Equivalent to get_value(Key, List, undefined) . get_value(Key, List, Default) -> term() Types Key = term() Default = term() List = [term()] Returns the value of a simple key/value property in List . If lookup(Key, List) would yield {Key, Value} , this function returns the corresponding Value , otherwise Default is returned. See also: get_all_values/2 , get_bool/2 , get_value/2 , lookup/2 . is_defined(Key, List) -> bool() Types Key = term() List = [term()] Returns true if List contains at least one entry associated with Key , otherwise false is returned. lookup(Key, List) -> none | tuple() Types Key = term() List = [term()] Returns the first entry associated with Key in List , if one exists, otherwise returns none . For an atom A in the list, the tuple {A, true} is the entry associated with A . See also: get_bool/2 , get_value/2 , lookup_all/2 . lookup_all(Key, List) -> [tuple()] Types Key = term() List = [term()] Returns the list of all entries associated with Key in List . If no such entry exists, the result is the empty list. See also: lookup/2 . normalize(List, Stages) -> List Types List = [term()] Stages = [Operation] Operation = {aliases, Aliases} | {negations, Negations} | {expand, Expansions} Aliases = [{Key, Key}] Negations = [{Key, Key}] Key = term() Expansions = [{Property, [term()]}] Property = atom() | tuple() Passes List through a sequence of substitution/expansion stages. For an aliases operation, the function substitute_aliases/2 is applied using the given list of aliases; for a negations operation, substitute_negations/2 is applied using the given negation list; for an expand operation, the function expand/2 is applied using the given list of expansions. The final result is automatically com- pacted (cf. compact/1 ). Typically you want to substitute negations first, then aliases, then perform one or more expansions (sometimes you want to pre- expand particular entries before doing the main expansion). You might want to substitute negations and/or aliases repeatedly, to allow such forms in the right-hand side of aliases and expansion lists. See also: compact/1 , expand/2 , substitute_aliases/2 , substitute_negations/2 . property(Property) -> Property Types Property = atom() | tuple() Creates a normal form (minimal) representation of a property. If Property is {Key, true} where Key is an atom, this returns Key , otherwise the whole term Property is returned. See also: property/2 . property(Key, Value) -> Property Types Key = term() Value = term() Property = atom() | tuple() Creates a normal form (minimal) representation of a simple key/value property. Returns Key if Value is true and Key is an atom, oth- erwise a tuple {Key, Value} is returned. See also: property/1 . split(List, Keys) -> {Lists, Rest} Types List = [term()] Keys = [term()] Lists = [[term()]] Rest = [term()] Partitions List into a list of sublists and a remainder. Lists contains one sublist for each key in Keys , in the corresponding order. The relative order of the elements in each sublist is preserved from the original List . Rest contains the elements in List that are not associated with any of the given keys, also with their original relative order preserved. Example: split([{c, 2}, {e, 1}, a, {c, 3, 4}, d, {b, 5}, b], [a, b, c]) returns {[[a], [{b, 5}, b],[{c, 2}, {c, 3, 4}]], [{e, 1}, d]} substitute_aliases(Aliases, List) -> List Types Aliases = [{Key, Key}] Key = term() List = [term()] Substitutes keys of properties. For each entry in List , if it is associated with some key K1 such that {K1, K2} occurs in Aliases , the key of the entry is changed to Key2 . If the same K1 occurs more than once in Aliases , only the first occurrence is used. Example: substitute_aliases([{color, colour}], L) will replace all tuples {color, ...} in L with {colour, ...} , and all atoms color with colour . See also: normalize/2 , substitute_negations/2 . substitute_negations(Negations, List) -> List Types Negations = [{Key, Key}] Key = term() List = [term()] Substitutes keys of boolean-valued properties and simultaneously negates their values. For each entry in List , if it is associated with some key K1 such that {K1, K2} occurs in Negations , then if the entry was {K1, true} it will be replaced with {K2, false} , otherwise it will be replaced with {K2, true} , thus changing the name of the option and simultaneously negating the value given by get_bool(List) . If the same K1 occurs more than once in Negations , only the first occurrence is used. Example: substitute_negations([{no_foo, foo}], L) will replace any atom no_foo or tuple {no_foo, true} in L with {foo, false} , and any other tuple {no_foo, ...} with {foo, true} . See also: get_bool/2 , normalize/2 , substitute_aliases/2 . unfold(List) -> List Types List = [term()] Unfolds all occurrences of atoms in List to tuples {Atom, true} . Ericsson AB stdlib 1.17.3 proplists(3erl)
All times are GMT -4. The time now is 01:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy