Exercise: Another Game, Maze
After learning so many newand strange concepts—references and structures—you deserve a little diversion. The following exercise demonstrates a structure and a few references by allowing you to play a simple game.
In the manner of classic games such as Adventure, Zork, and Hunt the Wumpus, you will be placed in a maze from which you must find your way out. The maze is featureless, consisting of only rooms with at least one doorway. The doorways lead to adjacent rooms to the north, south, east, or west. The object is to find the secret room. You'll soon learn, however, that only a couple of paths actually lead to that room; there are many dead-end paths.
To get started, type Listing 13.1 and save it as Maze. Running ...
Get SAMS Teach Yourself Perl in 24 Hours THIRD EDITION now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.