in reply to Re: Perl Hashes, keys under keys (I think)?
in thread Perl Hashes, keys under keys (I think)?


Ok well I think I may have answered my own question.

I found this link below. (You have to view the google cached version because the page no longer exists.).

"http://webcache.googleusercontent.com/search?q=cache:yVSNSleva3EJ:docstore.mik.ua/orelly/perl4/lperl/ch05_02.htm+perl+hash+-+hash+element+overwriting+next+element&cd=1&hl=en&ct=clnk&gl=us"

It basically says "Last one in wins". So I added a $count variable that increments after each 'WAITING' user, and then resets it to zero after executing each 'OWNER' record.

So I changed the following hash assignment line for the WAITING user to this:

$records{"$fields[1]"}{ "WAITING$count" } = { USER => "$fields[5]", FILENAME => "$fields[0]", PID => "$fields[6]", TIME => "$fields[9]", DATE => (join " ", "$fields[10] $fields[11]"), WAITERS => [] };

Can anyone think of a way where it would be a bad idea to do it this way?


Thanks,
Matt


.