Section B.9. Chapter 10, IO


B.9. Chapter 10, I/O

  • Don't use bareword filehandles. [Filehandles]

  • Use indirect filehandles. [Indirect Filehandles]

  • If you have to use a package filehandle, localize it first. [Localizing Filehandles]

  • Use either the IO::File module or the three-argument form of open. [Opening Cleanly]

  • Never open, close, or print to a file without checking the outcome. [Error Checking]

  • Close filehandles explicitly, and as soon as possible. [Cleanup]

  • Use while (<>), not for (<>). [Input Loops]

  • Prefer line-based I/O to slurping. [Line-Based Input]

  • Slurp a filehandle with a do block for purity. [Simple Slurping]

  • Slurp a stream with Perl6::Slurp for power and simplicity. [Power Slurping]

  • Avoid using *STDIN, unless you really mean it. [Standard Input]

  • Always put filehandles in braces within any print statement. [Printing to Filehandles]

  • Always prompt for interactive input. [Simple Prompting]

  • Don't reinvent the standard test for interactivity. [Interactivity]

  • Use the IO::Prompt module for prompting. [Power Prompting]

  • Always convey the progress of long non-interactive operations within interactive applications. [Progress Indicators]

  • Consider using the Smart::Comments module to automate your progress indicators. [Automatic Progress Indicators]

  • Avoid a raw select when setting autoflushes. [Autoflushing]



Perl Best Practices
Perl Best Practices
ISBN: 0596001738
EAN: 2147483647
Year: 2004
Pages: 350
Authors: Damian Conway

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