Home > Articles > Programming > Perl

  • Print
  • + Share This


Perl and network programming were made for each other. Perl's strong text-processing abilities combine with a flexible I/O subsystem to create an environment that is ideal for interprocess communication. This, combined with its native support for the Berkeley Sockets protocol, make Perl an excellent choice for network applications.

In this chapter we reviewed the essential components of Perl's I/O API. Filehandles are the fundamental object used for Perl input/output operations, and offer both line-oriented and byte-stream-oriented modes.

The STDIN, STDOUT, and STDERR filehandles are available when a program is started, and correspond to the standard input, output, and error devices. A script may open up additional filehandles, or reopen the standard ones on different files.

The standard I/O library, used by the <>, read(), and print() functions, improves I/O efficiency by adding a layer of buffering to input and output operations. However, this buffering can sometimes get in the way. One way to avoid buffering problems is to put the filehandle into autoflush mode. Another way is to use the lower-level syswrite() and sysread()i functions.

The IO::File and IO::Handle modules add object-oriented methods to filehandles. They smooth out some of the inconsistencies in Perl's original design, and pave the way to a smooth transition to IO::Socket.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.