/home/alex>perl -Mstrict -w -E 'say fileno(STDERR) ? "Filehandle" : "NA"'
Filehandle
/home/alex>perl -Mstrict -w -E 'say fileno(STDOUT) ? "Filehandle" : "NA"'
Filehandle
/home/alex>perl -Mstrict -w -E 'say fileno(STDIN) ? "Filehandle" : "NA"'
NA
/home/alex>
####
/home/alex>perl -Mstrict -w -E 'open my $f,"<","/dev/null"; say fileno($f)'
3
/home/alex>perl -Mstrict -w -E 'close STDIN; open my $f,"<","/dev/null"; say fileno($f)'
0
/home/alex>
####
/home/alex>perl -Mstrict -w -E 'my $f="foo"; say defined(fileno($f)) ? "filehandle" : "not a filehandle"'
not a filehandle
/home/alex>perl -Mstrict -w -E 'open my $f,"<","/dev/null"; say defined(fileno($f)) ? "filehandle" : "not a filehandle"'
filehandle
/home/alex>perl -Mstrict -w -E 'open my $f,"<",\my $mem; say defined(fileno($f)) ? "filehandle" : "not a filehandle"'
filehandle
/home/alex>perl -Mstrict -w -E 'close STDIN; open my $f,"<","/dev/null"; say defined(fileno($f)) ? "filehandle" : "not a filehandle"'
filehandle
/home/alex>
####
/home/alex>perl -Mstrict -w -E 'say fileno(STDERR); say fileno("STDERR"); say fileno("stderr"); say fileno("foobar")//"undef"; say fileno($_)//"undef" for (qw( STDERR stderr foo ))'
Name "main::foobar" used only once: possible typo at -e line 1.
2
2
2
undef
2
2
undef
/home/alex>