Exercises

  1. Using the random procedure (page 518), write a Tk script that draws a plot of a large number of random values. Use time (modulo the plot width) as the second dimension in the plot. Look for patterns in the plot.

  2. Many Tcl extensions come with libraries that are used by the extension itself but are not documented for users. Look through all the Tcl libraries for useful but undocumented utilities.

  3. Check the version of Expect that you are running. See if you can find a later one. Do your scripts still work?

  4. Use the time command and compare "string match" against regexp doing similar things. Is this reflected in the -gl and -re flags in the expect command?

  5. Time the UNIX sleep command and compare it to the built-in sleep command. At what point is the difference moot? How does this change if you are on a much slower or faster machine?

  6. What timestamp would exactly duplicate the default output of the UNIX date command? Time date and timestamp.

  7. Expect does not have a procedure that does the opposite of timestamp—converts a string to a date represented as an integer. Why is that? Write one anyway.

Get Exploring Expect now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.