There is nothing wrong with adding clarity to a statement that may otherwise be confusing or ambiguous. And there is nothing wrong with reducing the number of rules someone needs to know in order to correctly decipher a statement.
How does it add clarity or reduce the number or rules?
print FILEHANDLE LIST print FILEHANDLE print LIST
print { EXPR } LIST is not on the list at all
Where is the ambiguity?
print $fh map { "$_\n" } @list; print {$fh} map { "$_\n" } @list; $fh->print( map { "$_\n" } @list ); print( $fh map { "$_\n" } @list ); print( {$fh} map { "$_\n" } @list ); print $fh @list; print {$fh} @list; $fh->print( @list ); print( $fh @list ); print( {$fh} @list );
This is just such a case, because an argument given to print can start with either a filehandle or a variable. Depending on what follows, it can be very hard to tell which is intended without braces.
They're both called filehandles, both STDOUT and $fh, the first argument to print is always an optional filehandle followed by a LIST
STDOUT is a bareword filehandle and $fh is a lexical-scalar filehandle
In reply to Re^5: Split output by tabs
by Anonymous Monk
in thread Split output by tabs
by perlnoobster
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |