in reply to Re: Lose first element of hash in hash ..
in thread Lose first element of hash in hash ..
In the exist line I can find all things except the first one pushed onto the array. So $aoa->[0]->{THINGS}->{bed} does not exist but $aoa->[0]->{THINGS}->{chair} does exist. Very strange! And this repeats itself in all 3 $aoa[]sub initrooms { my (@aa, %things, $b, @ar, $t, $de, $ex, $th, @a); open (RF, "rooms.txt") or die "could not open datafile: $!"; undef $/; @ar = split (/0/, <RF>); $/ = "\n"; foreach (@ar) { ($t, $de, $ex, $th) = split /:/, $_; if ($th eq //) { next; } %things = split /-/, $th; print %things; (all elements present) push @a, { TITLE => $t, TEXT => $de, EXITS => $ex, THI +NGS => {%things} }; } return \@a; } sub lookat { my @i; my ($id, $i, $item); my ($tg, $cr, $aoa) = @_; if (exists ($aoa->[$cr]->{THINGS}->{$tg})) { print color("bold blue"), "\n", $aoa->[$cr]->{THINGS}- +>{$tg}, color("reset"); return; } print "\nHmm .. where?"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Lose first element of hash in hash ..
by GrandFather (Saint) on Mar 11, 2010 at 10:55 UTC | |
by LanX (Saint) on Mar 11, 2010 at 11:18 UTC | |
by theantler (Beadle) on Mar 11, 2010 at 11:38 UTC | |
|
Re^3: Lose first element of hash in hash ..
by Svante (Sexton) on Mar 11, 2010 at 12:12 UTC | |
by Corion (Patriarch) on Mar 11, 2010 at 12:17 UTC | |
by Svante (Sexton) on Mar 11, 2010 at 12:43 UTC | |
by theantler (Beadle) on Mar 11, 2010 at 16:41 UTC |