Workshop
Quiz
1: | To have data generated by your program display a page at a time, use
open(M, "| more") || die; print M "data...data...data....\n"; open(M, ">more") || die; print M "data..data...data...\n";
| 2: | Which value of $foo is used in this statement: $r=`dir $foo`?
The shell's value for $foo. Perl's value of $foo is substituted, and then the dir is run.
| 3: | Which of the following tasks changes depending on what system you have?
Finding the amount of free disk space Getting a directory listing
|
AnswersA1:
| Either a or b. In the case of a, all output of myprog.pl is fed to more. In the case of b, any data written to the M file descriptor is fed to more for paging. | A2:
| b. To protect $foo from Perl's expansion, you use qx`dir $foo`. | A3:
| a only. Choice b can be done with glob, <*> or opendir and readdir, and c is done with rmdir. |
Activities
Use the statistics functions in Hour 8, "Functions," to display even more statistics about the sizes of files in Listing 11.1. If you have a Unix system, add your particular flavor of Unix to the freespace() function. Use the Linux example as a starting point.
|