Exercises

See Appendix A for answers.

  1. Write a program that reads a file containing a list of lines composed of a user name, a company name, and an email address separated by colons. A sample line might look like this:

    John Doe:Foo Technologies:jdoe@footech.com

    Print out each field in formatted columns. Use format and write.

  2. Add a top-of-page format to the previous program. (If your file is relatively short, you might need to set the pagelength to something like 10 lines so that you can get multiple instances of the top-of-page.)

  3. Add a sequentially increasing page number to the top-of-page, so that you get page 1, page 2, and so on, in the output.

Get Learning Perl on Win32 Systems 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.