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

The uninitialized value error means that you used $key without having assigned it a value. You seem to understand that already.

Unless you post your code no one can point out the error in your code.

Replies are listed 'Best First'.
Re^4: Multiline variables
by theantler (Beadle) on Mar 09, 2010 at 17:44 UTC
    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; }
      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?