$ perl -E' my $fh = \*STDOUT; say $fh "test"; say $fh == STDOUT || 0; say $fh eq STDOUT || 0; say $fh == *STDOUT || 0; say $fh eq *STDOUT || 0; say fileno($fh) == 1 || 0; say fileno($fh) == fileno(STDOUT) || 0; ' test 0 0 0 0 1 1
perl -E' open my $fh, ">&", *STDOUT or die; say $fh "test"; say $fh == STDOUT || 0; say $fh eq STDOUT || 0; say $fh == *STDOUT || 0; say $fh eq *STDOUT || 0; say fileno($fh) == 1 || 0; say fileno($fh) == fileno(STDOUT) || 0; ' test 0 0 0 0 0 0
$ perl -E' local *STDOUT; open STDOUT, ">&", 1 or die; open my $fh, ">&=", *STDOUT or die; say $fh "test"; say $fh == STDOUT || 0; say $fh eq STDOUT || 0; say $fh == *STDOUT || 0; say $fh eq *STDOUT || 0; say fileno($fh) == 1 || 0; say fileno($fh) == fileno(STDOUT) || 0; ' test 0 0 0 0 0 1
$ perl -E' local *STDOUT; open STDOUT, ">&", 1 or die; open my $fh, ">&=", 1 or die; say $fh "test"; say $fh == STDOUT || 0; say $fh eq STDOUT || 0; say $fh == *STDOUT || 0; say $fh eq *STDOUT || 0; say fileno($fh) == 1 || 0; say fileno($fh) == fileno(STDOUT) || 0; ' test 0 0 0 0 1 0
In reply to Re: Testing whether a file handle is attached to STDOUT
by ikegami
in thread Testing whether a file handle is attached to STDOUT
by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |