CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
quick question on associative arrays

 



martialartsdrum
Novice

Nov 6, 2011, 8:48 AM

Post #1 of 4 (1063 views)
quick question on associative arrays Can't Post

Hi,

I originally put this in beginners, ~ 100 views with no response.
Hopefully, I can get a response here. I really do need the assistance.


I have ~ 10 associative arrays with data such as:

%Vol_Name = Vol_ID, Vol_Name
%Status = Vol_ID, Status
%Date = Vol_ID, Date
etc.

What I would like to do, is loop through the Vol_Name array
and flag all Vol_ID's of the other arrays.

pseudo code:

loop for size of Vol_Name
{
Get Vol_ID from Vol_Name array
go through all the other arrays, searching for Vol_ID
if found
display data().
}

How can I accomplish this?

thanks

John


FishMonger
Veteran / Moderator

Nov 7, 2011, 6:33 PM

Post #2 of 4 (879 views)
Re: [martialartsdrum] quick question on associative arrays [In reply to] Can't Post

You need to provide more details on what you're doing and what you need to accomplish, but based on what you've posted I can say that you're using the wrong data structure. Instead of 3 separate hashes, you should be using 1 HoH ( hash of hashes).


avis
New User

Nov 7, 2011, 10:44 PM

Post #3 of 4 (864 views)
Re: [FishMonger] quick question on associative arrays [In reply to] Can't Post

hey your problem is not descriptive and its not clear , can you specify your problem clearly.... Like
What input you need and what output you expect???

~Avis.


cycleops
Novice

Dec 3, 2011, 1:00 PM

Post #4 of 4 (752 views)
Re: [martialartsdrum] quick question on associative arrays [In reply to] Can't Post

Not 100% sure I understand the problem, but I'll try and answer.
Noted that you originally posted in beginner.


# get the keys for the Vol_Name array and loop through them
foreach $volume (keys %Vol_Name)
{
# $volume will be set to each of the keys

# get the value from the associative arrays
printf ("The value in the Status array for %s is: %s\n", $volume, $Status{$volume});
printf ("The value in the Date array for %s is: %s\n", $volume, $Date{$volume});
# etc...
}

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives