The perldoc for fileno says
Filehandles connected to memory objects via new features of open may return undefined even though they are open.
Is this referring to new style calls to open in general, or to the IO::Scalar style calls to open?
The perldoc for fileno says
Filehandles connected to memory objects via new features of open may return undefined even though they are open.
Is this referring to new style calls to open in general, or to the IO::Scalar style calls to open?
This code seems to say that it applies only to the IO::Scalar version of open. This is probably because there is no underlying OS level fileno associated with the filehandle.
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
my $fakefile = "foo\nbar\nbaz\n";
open my $fake, "<", \$fakefile
or die "could not open fakefile [$fakefile]: $!";
open my $script, "<", $0
or die "could not open self for reading: $!";
print "fake: ", my_fileno($fakefile), "\nreal: ", my_fileno($script), "\n";
sub my_fileno {
my $fileno = fileno shift;
$fileno //= "undef";
return $fileno;
}