Length: 45 minutes


One of the more frequently-asked questions in the FAQ is:

How do I change one line in a file/delete a line in a file/insert a line in the middle of a file/append to the beginning of a file?

Unfortunately, the FAQ answer isn't very satisfying:

Those are operations of a text editor. Perl is not a text editor.

Now, however, there is a better answer. New in Perl 5.8, Perl is a text editor. The Tie::File module associates a Perl array with the lines of a file; you can modify the array with assignments, or push, or splice, or reverse, or whatever you prefer, and your changes will be instantly propagated to the file.

I'll introduce this module and show how to use it and how it works. I'll demonstrate some of its more advanced features. Next time you want to change one line in a file, delete a line from a file, insert a line in the middle of a file, or append to the beginning of a file, why not let Tie::File do the work for you?

Complete Slides

  1. Tie::File
  2. Frequently Asked Questions
  3. Frequently Asked Questions
  4. Tie::File
  5. Examples
  6. Examples
  7. Examples
  8. Examples
  9. Examples
  10. Another FAQ
  11. Caching
  12. Writing Strategy
  13. Deferred Writing
  14. Autodeferring
  15. Miscellaneous Features
  16. Summary
  17. Where to Get it

Get the module

Return to: Universe of Discourse main page | Perl Paraphernalia | Classes and Talks