Alternate Matches using Perl
Here is an example of alternate matches:
/[Ww](einman|eb[Mm]onster)/
if($input=~/^([Yy])|([Yy])es\b/
{ print "Let us play!\n" }
else
{ print "Okay. Thanks anyway.\n" }
The "or" structure (|
) allows the script to match Y
, y
, Yes
, or yes
.
How Programs Communicate
Programs can communicate with each other in a variety of ways. They can use files, anonymous/named
pipes, System V inter-process messaging primitives, BSD sockets, and TLI (Transport Layer Interface).
Socket and TLI communications come under the purview of "networking," a step up from the other IPC
(inter-process communication) mechanisms, because they do not constrain the communicating processes to be on the same machine.
This module provides a primer on socket communications and builds simple client/server configurations using Graham Barr's IO library (part of the standard Perl distribution). This knowledge is put to use in the next module, where we build an asynchronous message passing module,
and another for doing remote procedure calls (RPC). Networking is the second of four important technologies that we discuss in this course. The others are 1) user interfaces, 2) persistence, and 3) code generation. This module is as much about the technology as it is about Perl's support for networking. Andrew Tanenbaum's textbook on computer networks is a wonderful introduction to computer networking.
Advanced Perl Programming