note
shmem
<blockquote><i>And now try it with
<c>
my %handle = ( out => *STDOUT,
err => *STDERR );
print {$handle{out}} "Test\n"; # Not possible without braces.
</c>
</i></blockquote>
<p>
This is one of the rare cases, in which a BLOCK (which returns a file handle) is needed. For such a rare case, which anyways would have better been written as
</p>
<code>
my %handle = ( out => *STDOUT,
err => *STDERR );
my $fh = $handle{out};
print $fh "Test\n"; # Look, ma! no curlies at all.
</code>
<p>the appropriate syntax is glorified as "Best Practice"! Oh my.</p>
1003565
1003616