Workshop

 <  Day Day Up  >  

Quiz

1:

To have data generated by your program display a page at a time, use

  1. perl myprog.pl more

  2. open (M, " more") die; print M "data...data...data....\n";

  3. open(M, ">more") die; print M "data..data...data...\n";

2:

Which value of $foo is used in this statement: $r=`dir $foo` ?

  1. The shell's value for $foo .

  2. 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?

  1. Finding the amount of free disk space

  2. Getting a directory listing

  3. Deleting a directory

Answers

A1:

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.

 <  Day Day Up  >  


SAMS Teach Yourself Perl in 24 Hours
Sams Teach Yourself Perl in 24 Hours (3rd Edition)
ISBN: 0672327937
EAN: 2147483647
Year: 2005
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net