in reply to array games??
As to the array: why not use a hash, the command would be the key, and the location the value.
That way you can simply do a hash lookup to retrieve the location for a command, i.e. $hash{'north'} will yield 'library' as a location.my %hash = ('north' => 'library', 'south' => 'kitchen', 'east' => 'hallway');
As to your second problem:
is not what you want. If you just want to read from stdin, simply use <> rather than <1>. If you want an infinite loop (although I don't think so since you're not reading anything in the body of the loop) just use while (1) {...}.while(<1>){ ... }
Hope this helps, -gjb-
Update: Oops, as graff points out (thanks) I missed the assignment to $action, but yes, anyway the condition for the while will always fail which is what I tried to explain.
|
|---|