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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double Hash?

Status
Not open for further replies.

mikerobb

Programmer
Nov 7, 2001
13
US
Hi-

I have a double hash and am trying to do a foreach (sort) on the inner hash.

This code doesn't want to work. Any ideas?


my $from_state,$to_state;
foreach $from_state (sort keys %rt::states) {
foreach $to_state (sort keys %rt::states{$from_state}) {

it bombs on the syntax of the 2nd foreach statement.

The hashes are valid and defined and work.
warn "$rt::states{'one'}{'two'}{'data'}";
^^^-- this will output the correct data that has been set into it.

Any ideas?

-TIA!

--Mike Robb
 
If my memory is correct I think you need another pair of braces {} around the hash in the second foreach:-

sort keys %{ rt::states{$from_state}}

paulf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top