# Unlike with python, the ioctl needs to be hard-coded. # FIONREAD == 0x4004667 should be true of macOS. # On the other hand, Perl startup time is lower than Python. perl -MIO::Select -e ' my $s = IO::Select->new(\*STDIN); if ($s->can_read(0.5)) { ioctl(STDIN, 0x4004667f, $buf = pack("L", 0)) or exit 2; exit !unpack("L", $buf); } exit 1; '