A stylistic advice reference is Perl Best Practices, Chapter 10 (I/O), Item 136: Always put filehandles in braces within any print statement:
It's easy to lose a lexical filehandle that's being used in the argument list of a print:
print $file $name, $rank, $serial_num, "\n";Putting braces around the filehandle helps it stand out clearly:
The braces also convey your intentions regarding that variable; namely that you really did mean it to be treated as a filehandle, and just didn't forget a comma.print {$file} $name, $rank, $serial_num, "\n";
An alternative syntax using IO::Handle:
use IO::Handle; $file->print( $name, $rank, $serial_num, "\n" );
In reply to Re^2: Handling multiple output files simultaneously using arrays of filehandles and filenames
by eyepopslikeamosquito
in thread Handling multiple output files simultaneously using arrays of filehandles and filenames
by Cosmic37
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |