http://www.perlmonks.org?node_id=617160


in reply to perldoc -f fileno

You can open a filehandle that uses a scalar reference as the data source, like this:
use strict; use warnings; my $data = "a\nb\n"; open my $fh, '<', \$data; my $fileno = fileno $fh; printf "fileno: %s\n", defined $fileno ? $fileno : '(undef)'; print for <$fh>; close $fh; $fileno = fileno $fh; printf "fileno: %s\n", defined $fileno ? $fileno : '(undef)';