Going Deeper

Whole books have been written on using the various platform-specific bits of Perl (or for avoiding them). To keep this chapter to the minimum, I've skipped over a number of features that you might want to explore on your own when you're done with this book.

Pipes

Probably the biggest feature that was not talked about in this book is the use of pipes. A pipe is sort of a channel from which you can read data, and to which you can send data. The pipe can connect to the standard input and output of your script and some other program, or it can also connect to a device such as a printer, or a network connection such as a socket.

On Unix, you can open a pipe as if it were just another file handle, and read and write to it that way. The pipe can be to another program, or to another process running the same program. You can also use named pipes that might exist on your system. The perlipc man page contains more information about using pipes.

On Windows, you can use regular pipes with open as on Unix to other processes running on the system. For named pipes, look for the Win32::Pipe module.

Signals

Signals are a Unix feature that let you trap various errors and messages and handle them in some sensible way. The %SIG hash contains references to various signal handlers. Signals only work in Unix; see the perlipc man page for more information.

Basic Networking

The Unix version of Perl has a number of built-in functions for handling low-level networking commands and sockets. Most of these functions are unsupported on other platforms, superseded by various platform-specific networking modules. If you're a real network fiend, feel free to visit the perlipc man page for plenty of information on sockets and network programming.

If you just want to, say, retrieve a Web page from the Internet, there are modules that will do that for you without you needing to know anything about what a TCP is. I'll discuss those on Day 20, “Odds and Ends.”

Creating User Interfaces with Perl

Creating a graphical user interface (GUI) in Perl isn't easy, and it's not very cross- platform. But it is possible.

One of the best ways to create GUIs in Perl is with the Tk package. Tk is a simple way of creating and managing user interface widgets, originally associated with the TCL language, but now available for Perl as well. Tk is available for both Unix and Windows, and has a platform-specific look for each one. Perl/Tk has an FAQ at http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.perl.tk.html.

The Win32::OLE module can enable you to create interfaces in Visual Basic, and then control them with OLE automation. See Win32::OLE.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset