Perl Best Practices [Electronic resources] نسخه متنی
لطفا منتظر باشید ...
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 ]