start page | rating of books | rating of authors | reviews | copyrights

Learning Perl on Win32 Systems

Learning Perl on Win32 SystemsSearch this book
Previous: 8.7 File-Level my( ) Variables Chapter 8
Functions
Next: 9. Miscellaneous Control Structures
 

8.8 Exercises

See Appendix A, Exercise Answers for answers.

  1. Write a subroutine that takes a numeric value from 1 to 9 as an argument and then returns the English name (such as, one , two , or nine ). If the value is out of range, return the original number as the name instead. Test it with some input data; you'll probably have to write some sort of code to call the subroutine. (Hint: the subroutine should not perform any I/O.)

  2. Taking the subroutine from the previous exercise, write a program that takes two numbers and then adds them together, displaying the result as Two plus two equals four . (Don't forget to capitalize the initial word!)

  3. Extend the subroutine to return negative nine through negative one and zero . Try it in a program.


Previous: 8.7 File-Level my( ) Variables Learning Perl on Win32 Systems Next: 9. Miscellaneous Control Structures
8.7 File-Level my( ) Variables Book Index 9. Miscellaneous Control Structures