in reply to Re^2: Perl Hashes, keys under keys (I think)?
in thread Perl Hashes, keys under keys (I think)?
Hey hbm,
I think I got it working correctly. All's I really had to do was add a couple of lines (i.e. add $count++, as well as a "else" clause, etc...).
Here's what I got:
if ($fields[5] =~ /(OWNER|WAITING)/) { $x++; $state = $1; if ($state eq 'OWNER') { $count = 0; } if ($state eq 'WAITING') { $state .= "-$count"; $count +++; } @fields = split " ", $temp[$x]; print "$state --- @fields\n"; #Add record to hash based on RECORD_ID $records{"$fields[1]"}{ $state } = { USER => "$fields[5]", FILENAME => "$fields[0]", PID => "$fields[6]", TIME => "$fields[9]", DATE => (join " ", "$fields[10] $fields[11]"), ELAPSED => [] }; #Increment to Next Line $x++; } else { $records{"$fields[1]"}{ "WAITING-$count" } = { USER => "$fields[5]", FILENAME => "$fields[0]", PID => "$fields[6]", TIME => "$fields[9]", DATE => (join " ", "$fields[10] $fields[11]"), ELAPSED => [] }; $count++; $x++; }
Thanks Again,
Matt
.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Perl Hashes, keys under keys (I think)?
by hbm (Hermit) on Sep 21, 2011 at 12:36 UTC | |
by mmartin (Monk) on Sep 21, 2011 at 20:51 UTC | |
by hbm (Hermit) on Sep 22, 2011 at 13:59 UTC | |
by mmartin (Monk) on Sep 22, 2011 at 15:02 UTC | |
by mmartin (Monk) on Sep 22, 2011 at 16:11 UTC |
In Section
Seekers of Perl Wisdom