Let me be more descriptive.  IO.xs has some useful features.
Most of the IO::*.pm modules do not, especially Handle and File.

Here's all you need from the low-level IO.xs stuff, the things that
aren't in straight Perl (although some can be done, but less
conveniently):

    require IO::Handle;
    my @IMPORTS;
    BEGIN { @IMPORTS = (qw/ blocking clearerr error formline getpos
                        setbuf setpos setvbuf sync untaint / ); } 
    use subs @IMPORTS;

    for my $func (@IMPORTS) {
        no strict 'refs';
        no warnings;  # squelch wicked coercion of ($;$) in IO.xs's io_blocking()
        *$func = \&{"IO::Handle::$func"};
    } 

    untaint(*STDIN);
    formline(*STDERR, "^" . ("<" x 72) . "~~\n", "can this work " x 40);

Or, if you like, somewhat more robustly even than silly Mr
I-can't-do-compile-time-checks Method calls:

    require FileHandle;
    {
        no warnings;  # next line predeclares w/ context coercer of (@)

        use subs qw/ blocking clearerr error formline getpos setbuf setpos
                            setvbuf sync untaint /;

        sub clearerr(*)     { shift->clearerr       }
        sub blocking(*,$)   { shift->blocking(@_)   }
        sub error(*)        { shift->error          }
        sub formline(*$@)   { shift->formline(@_)   }
        sub getpos(*)       { shift->getpos         }
        sub setbuf(*)       { shift->setbuf(@_)     }
        sub setpos(*$)      { shift->setpos(@_)     }
        sub setvbuf(*$$)    { shift->setvbuf(@_)    }
        sub sync(*)         { shift->sync           }
        sub untaint(*)      { shift->untaint        }
    } 

    untaint(STDIN);
    formline(STDERR, "^" . ("<" x 72) . "~~\n", "can this work " x 40);

That's not to say that IO::Socket isn't nice to have.  But this
is usually all you need of it:

    require IO::Socket;
    sub inet_socket { IO::Socket::INET->new(@_) } 

    *Mailer = inet_socket("localhost:smtp");
    print scalar <Mailer>;

Select Saver isn't bad either.

--tom

Reply via email to