IO#
Load the core IO modules - IO::Handle, IO::File, IO::Seekable, IO::Pipe, IO::Socket, IO::Dir - in one use.
This is the module every IO:: class rests on: IO::Handle, IO::File, IO::Seekable, IO::Dir, IO::Socket and IO::Pipe all require it, so use IO; is enough to have the whole family available.
IO itself defines nothing you call as IO::something. Every method lives in the class it belongs to - IO::Seekable, IO::File, IO::Handle, IO::Socket, IO::Poll - and use IO qw(File Handle) simply loads the named subset.
It also defines the numeric constants those classes need: POLLIN, POLLPRI, POLLOUT, POLLRDNORM, POLLWRNORM, POLLRDBAND, POLLWRBAND, POLLNORM, POLLERR, POLLHUP and POLLNVAL in IO::Poll, and _IOFBF, _IOLBF, _IONBF, SEEK_SET, SEEK_CUR and SEEK_END in IO::Handle.
use strict;
use IO qw(Handle File Seekable);
use IO::Seekable; # exports SEEK_SET, SEEK_CUR, SEEK_END
my $fh = IO::File->new($path, "w+") or die $!;
$fh->autoflush(1);
$fh->print("hello\n");
$fh->seek(0, SEEK_SET);
print "read back: ", $fh->getline; # read back: hello
printf "SEEK_END %d, _IONBF %d\n", SEEK_END, IO::Handle::_IONBF; # 2, 2
This is a native implementation of the XS half of IO 1.56 - the handle methods that need C (blocking, ungetc, error, clearerr, untaint, flush, sync, setbuf, setvbuf, getline/getlines/gets, IO::Seekable’s getpos/setpos, IO::File->new_tmpfile, IO::Poll’s _poll and IO::Socket’s sockatmark). Every IO::* module’s Perl is upstream’s, unchanged.
Differences from upstream#
None.
Modules#
IO::Compress- read/write compressed data in multiple formatsIO::Dir- supply object methods for directory handlesIO::File- supply object methods for filehandlesIO::Handle- supply object methods for I/O handlesIO::Pipe- supply object methods for pipesIO::Poll- Object interface to system poll callIO::Pty- Pseudo TTY object classIO::Seekable- supply seek based methods for I/O objectsIO::Select- OO interface to theselectsystem callIO::Socket- Object interface to socket communicationsIO::Tty- Pseudo-terminals and the terminal constants: the compiled part underIO::Pty(a pty master and its slave as handles) andIO::Tty.IO::Zlib- IO:: style interface to Compress::Zlib