Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hash of a hash of a hash issue...

Status
Not open for further replies.

Firemyst

Programmer
Mar 10, 2003
62
US
I'm working on upgrading a calendar for my company. We currently build a hash of a hash which holds an array. For example:

push(@{$events{$datestamp}{"event_num"}},$event_num);
and reference as:
${$events{$datestamp}{"event_num"}}[$x]

The datestamp holds the date of the event, and the event number is the unique identifier. There could be more than one "event_num" per day, hence the array in the hash.

Now, we need to expand it so that we can build a hash which first holds the different calendars (the number for each request is dynamic, so I can't declare a fixed number of variables). The "key" being the identifier for which calendar's data we want to access. Then, depending on the calendar, accesses the hash example above.

I've tried building it like:
$other_cals{$cal_X} = %events;

Is this correct and/or possible? If so, how do I then reference the data? I cannot seem to extract anything.

I've tried stuff like:
${$other_cals{"demo2"}{${$events{$datestamp}{"event_num"}}[0]}}
$other_cals{"demo2"}{$events{$datestamp}{"event_num"}}[0]

And so on. I know there's data being read because when I print:

${$events{$datestamp}{"event_num"}}[0]

I receive values.

Thanks!
 
I think $other_cals{$cal_X} = \%events

would do the trick, i.e. use the reference to the hash.
 
If I use:
$other_cals{$cal_X} = \%events

how do I properly reference an item in the %events hash through the %other_cals hash?

I can't seem to figure that out. The latest I have is:
$other_cals{"demo2"}{{$datestamp}{"event_num"}}[0]

Thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top