What's going on is that the sys/ioctl.ph file (at least the one on my system) defines a bunch of subs, however, it does not use something like Exporter to do so, it just defines them in whatever the current package happens to be. Also, require only loads a file once: if you have require 'sys/ioctl.ph' in your package main (i.e. test.pl) that gets called first, then the require 'sys/ioctl.ph' in package funnybusiness has no effect, and therefore, the sub funnybusiness::FIONREAD never gets defined.
There are several possible solutions, which one is most "elegant" depends... One possible solution might be to use do instead of require, because it always runs the file, no matter how many times it's been run before, but keeping in mind the error checking described in the documentation of do. Also, I'd move that do outside of the sub s1, there's no need for the file to get loaded every time the sub is called. As an alternative to do, one could do delete $INC{'sys/ioctl.ph'}; require 'sys/ioctl.ph'; to make sure the require loads the file (see %INC).
Yet another solution might be to do the following in one of the library files:
{
package Sys::Ioctl;
BEGIN {
delete $INC{'sys/ioctl.ph'};
require 'sys/ioctl.ph';
}
}
And then to use Sys::Ioctl::FIONREAD() everywhere. This could also be separated out into its own Sys/Ioctl.pm file, which could in turn use Exporter to get those definitions exported in the usual manner. This is probably the solution I would favor in a larger application.