For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2005 > Hash-Hash-Hash-List-List-List









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Hash-Hash-Hash-List-List-List
mike

2005-07-26, 9:00 am

Hi,
I am fairly new to perl and not loving the syntax! Basically what i
have is a set of options, S1,S2,S3, which should return a list of a
list of data items: So:

First of all I got this working:

%res = (
A =>
{
A =>
{
A => "AAA",
B => "AAB"
}
}
B =>
{
A =>
{
A => "BAA",
B => "BAB"
}
}
)

and so forth and I can access the strings with:
print ("$res{"B"}{"A"}{"B"}");

but if i change the leaf nodes as:
%res = (
A =>
{
A =>
{
A => ["AAA", "optAAA"],
B => ["AAB", "optAAB"]
}
}
B =>
{
A =>
{
A => ["BAA", "optBAA"],
B => ["BAB", "optBAB"]
}
}
)
and now i want to iterate over the items in the list, I can't work out
how to do it!! I have spent the last 2 day with foreach loops and a
variety of $%@ variable prefixes tearning my hair out!


by the end i want something as:

%res = (
A =>
{
A =>
{
A => [
["AAA_1", ["optAAA_1_1, optAAA_1_2"]],
["AAA_2", ["optAAA_2_1, optAAA_2_2"]],
["AAA_3", ["optAAA_3_1, optAAA_3_2"]],
]
}
}
)

so that I can iterate over the "AAA_1", "AAA_2" in order that they are
given and perform operations on thier "opt" counterparts

I would be exceptionally gratefull for any help, especially if its
explained and simply!!


Regards


Mike

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com