home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeLearning Perl, 3rd EditionSearch this book

12.6. Exercises

See Section A.11, "Answers to Chapter 12 Exercises" for answers to the following exercises.

  1. [12] Write a program to ask the user for a directory name, then change to that directory. If the user enters a line with nothing but whitespace, change to his or her home directory as a default. After changing, list the ordinary directory contents (not the items whose names begin with a dot) in alphabetical order. (Hint: Will that be easier to do with a directory handle or with a glob?) If the directory change doesn't succeed, just alert the user -- but don't try show the contents.

  2. [4] Modify the program to include all files, not just the ones that don't begin with a dot.

  3. [5] If you used a directory handle for the previous exercise, rewrite it to use a glob. Or if you used a glob, try it now with a directory handle.

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.