Exercise: Playing a Little Game

This hour has really been full of Catch-22's: familiar operators behaving differently depending on context, a handful of new operators and functions, and quite a few new rules to remember about syntax. To keep you from developing any hang-ups, I've added this exercise, which puts your knowledge of arrays and lists to good use—a game.

Using your text editor, type the program from Listing 4.1 and save it as Hangman. As always, don't type the line numbers or their following colons (“1:”, etc.) Be sure to make the program executable according to the instructions you learned in Hour 1, “Introduction to the Perl Language.”

When you're done, try running the program by typing the following at a command line:

						Hangman

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.