Length: 3 hours
Prerequisites: Programmers should have had several months experience programming in Perl and some experience working on group projects.
Sometimes you'll write a function that takes too long to run because it produces too much useful information. A search function might locate ten thousand matches. A database query might return ten million records. What can you do?
Perl provides a simple and familiar model for dealing with such problems: The filehandle! Instead of reading every file in one giant gulp, we can use filehandles to staunch the flow of information, trickling it into the program in manageable gulps.
In this class, we'll see several important modules, such as File::Find and DBI, which use this approach. We'll go inside these modules and see how to implement filehandle-like data structures and objects ourselves. We'll see how to write functions that suspend themselves and then pick up later where they left off. We'll learn how to take long-running slow functions and convert them into speedy filehandle-like data generator objects.
This fundamental technique is a mainstay of programmers in other languages, but isn't as well-known as it should be. You'll be amazed at how many difficult problems become simple when you unleash the power of filehandles.
Sarah Burcham's review of this class from the 2002 Open Source Conference
If you liked these materials or found them useful, consider buying my book Higher-Order Perl, which discusses these matters in much greater detail.
Return to: Universe of Discourse main page | Perl Paraphernalia | Other Classes and Talksmjdemail@example.com