有时我必须使用裸词“STDOUT”,有时裸词不起作用,有时我可以使用裸词或其他形式。是否有规则告诉我何时必须选择表格,何时必须选择表格以及何时可以选择表格?
#!/usr/bin/env perl
use warnings;
use 5.12.0;
use utf8;
print STDOUT "Something\n"; # works
print \*STDOUT "Something\n"; # String found where operator expected
print { STDOUT } "Something\n"; # Bareword "STDOUT" not allowed while "strict subs" in use
print { \*STDOUT } "Something\n" # works
my $fh;
$fh = -t STDOUT ? STDOUT : STDERR; # Bareword "STDOUT"/"STDERR" not allowed while "strict subs" in use
$fh = -t STDOUT ? \*STDOUT : \*STDERR; # works
$fh = -t \*STDOUT ? \*STDOUT : \*STDERR; # works