# Associative Array

**URL:** <https://community.unix.com/t/associative-array/146837>\
**Category:** Shell Programming and Scripting\
**Created:** [September 30, 2003, 8:56am UTC](https://community.unix.com/t/associative-array/146837 "2003-09-30T08:56:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tine](https://community.unix.com/letter_avatar/tine/32/6_22734026db12803ebb3e059622ac3534.png) [@tine](https://community.unix.com/u/tine)\
**Post date:** [September 30, 2003, 8:56am UTC](https://community.unix.com/t/associative-array/146837/1 "2003-09-30T08:56:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tine](https://community.unix.com/letter_avatar/tine/32/6_22734026db12803ebb3e059622ac3534.png) [@tine](https://community.unix.com/u/tine)\
**Post date:** [September 30, 2003, 9:11am UTC](https://community.unix.com/t/associative-array/146837/2 "2003-09-30T09:11:07Z")

</div>

$temp\_uid[$s] = $entr-\>get\_value(uid);  
$temp\_waarde = $entr-\>get\_value(uid);  
$temp\_naam{$temp\_waarde} = $entr-\>get\_value(sn);

changed the [ to { but it still doesn't work..

---

<div class="post-metadata">

**Author:** ![google](https://community.unix.com/user_avatar/community.unix.com/google/32/65_2.png) [@google](https://community.unix.com/u/google)\
**Post date:** [September 30, 2003, 9:13am UTC](https://community.unix.com/t/associative-array/146837/3 "2003-09-30T09:13:05Z")

</div>

Ok, dumb question but what language, shell, system are you using?

---

<div class="post-metadata">

**Author:** ![cbkihong](https://community.unix.com/letter_avatar/cbkihong/32/6_22734026db12803ebb3e059622ac3534.png) [@cbkihong](https://community.unix.com/u/cbkihong)\
**Post date:** [September 30, 2003, 9:19am UTC](https://community.unix.com/t/associative-array/146837/4 "2003-09-30T09:19:07Z")

</div>

Looks 90% like it's Perl. At least these are all valid Perl statements. 😃

Without giving me a look at a larger part of your program I can't find out what's wrong.

For example, you said popup\_menu() doesn't work, but you didn't give us at a look of the full implementation of the subroutine, and what you are trying to pass to the subroutine.

---

<div class="post-metadata">

**Author:** ![tine](https://community.unix.com/letter_avatar/tine/32/6_22734026db12803ebb3e059622ac3534.png) [@tine](https://community.unix.com/u/tine)\
**Post date:** [September 30, 2003, 9:27am UTC](https://community.unix.com/t/associative-array/146837/5 "2003-09-30T09:27:24Z")

</div>

yes i am using perl..

I found out the problem, before i started filling the array, i declared it like this:  
%temp\_naam = ();

as soon as i removed this, it did work.

Thank you for your time!

Tine
