in reply to Re^2: Help me update stubborn perlfaq answers!
in thread Help me update stubborn perlfaq answers!

Ditto on the POSIX::close. I don't know about the portability of numeric file descriptors, but I recently used them.

I needed to test a method that uses perl's syswrite on a socket, so my first thought was "pipe." But perl's pipe() threatened me with "Perl's pipes use IO buffering..." so I used POSIX::pipe instead which returns numeric fds. But syswrite wants filehandles. So I did this:

my ($read_fd, $write_fd) = POSIX::pipe(); open(my $read_fh, "<&=$read_fd") or die "fdopen for read: $!"; open(my $write_fh, ">&=$write_fd") or die "fdopen for write: $!"; $write_fh->blocking(0); ... $client->{sock} = $write_fh; ... $client->_syswrite($topic, $msg) ... ok( sysread($read_fh, $buf, length($msg)), length($msg) );