in reply to Re^3: Multiline variables
in thread Multiline variables

I played some text based adventure games when I was a kid, and I want to re-create one of them and also in a re-imagined way .. Here is my very humble function to init the rooms .. It works now, is very minimum still.
sub initrooms { my (@ta, %things, $b, @ar, $t, $de, $ex, $th, @a); open (RF, "rooms.txt") or die "could not open datafile: $!"; $/ = undef; $b = (<RF>); $/ = "\n"; @ar = split /0/, $b; foreach (@ar) { ($t, $de, $ex, $th) = split ":", $_; if ($th eq "") { next; } @ta = split "-", $th; %things = @ta; push @a, { TITLE => $t, TEXT => $de, EXITS => $ex, TH +INGS => {%things} }; }; return \@a; }

Replies are listed 'Best First'.
Re^5: Multiline variables
by theantler (Beadle) on Mar 10, 2010 at 17:44 UTC
    Hmm .. I seem to lose the first element in the hash in each pass, but the other are there. Why would that happen, if anyone sees this?