O'Reilly logo

Sams Teach Yourself Perl in 21 Days, Second Edition by Rafe Colburn, Laura Lemay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Another Example: Stats with a Menu

Let's modify the stats example once more in this lesson to take advantage of just about everything you've learned so far in this book. I've modified stats such that instead of reading the values, printing everything, and then exiting, the script prints a menu of operations. You have a choice of the sort of operations you want to perform on the numbers in the data set.

Unlike the names.pl script from Day 8, however, which used a large while loop and a number of if tests to handle the menu, this one uses subroutines. In addition, it moves a lot of the calculations we performed in earlier versions of this script into the subroutine that actually uses those calculations, so that only the work that needs to be done ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required