Perl Object Environment
   HOME

TheInfoList



OR:

: ''For the Mach variant, see Mach (kernel)'' The Perl Object Environment or POE is a
library A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vir ...
of Perl modules written in the
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
by Rocco Caputo et al. From CPAN: :''"POE originally was developed as the core of a persistent object server and runtime environment. It has evolved into a general purpose multitasking and networking framework, encompassing and providing a consistent interface to other event loops such as Event and the Tk and
Gtk GTK (formerly GIMP ToolKit and GTK+) is a free and open-source cross-platform widget toolkit for creating graphical user interfaces (GUIs). It is licensed under the terms of the GNU Lesser General Public License, allowing both free and propriet ...
toolkits."''


POE Architecture: Layers of Abstraction

POE, The Perl Object Environment can be thought of as a tiny modular
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
. One or more POE programs or instances can be run concurrently and are generally well suited for
cooperative multitasking Cooperative multitasking, also known as non-preemptive multitasking, is a style of computer multitasking in which the operating system never initiates a context switch from a running process to another process. Instead, in order to run multiple ...
. The POE package consists of
namespace In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified. Namespaces ...
s and abstractions that guide future development of POE in an open-ended CPAN-style convention.


The event layer

The informal architecture consists of a set of layers with a
kernel Kernel may refer to: Computing * Kernel (operating system), the central component of most operating systems * Kernel (image processing), a matrix used for image convolution * Compute kernel, in GPGPU programming * Kernel method, in machine learn ...
on the bottom. This tiny kernel represents the events layer which operates as the main loop of each running POE instance. The first call is to the "event dispatcher" - POE::Kernel. The POE::Kernel namespace contains a suite of functions which are plugged into the kernel itself. These loop abstractions are designed after POE's standardized event loop bridge interface - POE::Loop. These can be mixed and matched as needed to provide runtime services and a lean facility for
interprocess communication In computer science, inter-process communication or interprocess communication (IPC) refers specifically to the mechanisms an operating system provides to allow the processes to manage shared data. Typically, applications can use IPC, categoriz ...
. The basic functions are POE::Loop::Event, POE::Loop::Poll and POE::Loop::Select. Also available are POE::Loop::Tk and POE::Loop::Gtk which offer hooks into other loop bridges in the external environment. If that isn't enough, the POE::Loop kernel abstraction provides reusable signal callbacks, time or alarm callbacks, and filehandle activity callbacks as well as administrative functions such as initializing, executing, and finalizing event loops. There is also a higher level packaging framework - POE::Macro and a debugging utility for testing them called POE::Preprocessor. This framework has yielded POE::Macro::UseBytes. :NOTE: As the Perl tradition mandates, POE is also a moving target. Always check
CPAN The Comprehensive Perl Archive Network (CPAN) is a repository of over 250,000 software modules and accompanying documentation for 39,000 distributions, written in the Perl programming language by over 12,000 contributors. ''CPAN'' can denote eit ...
to see what new goodies the community has placed in the archive. (...and remember Perl's Motto: "There's more than one way to do it" per
Larry Larry is a masculine given name in English, derived from Lawrence or Laurence. It can be a shortened form of those names. Larry may refer to the following: People Arts and entertainment * Larry D. Alexander, American artist/writer *Larry Boone ...
) The Running Kernel operates through primordial
finite-state machine A finite-state machine (FSM) or finite-state automaton (FSA, plural: ''automata''), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number o ...
s constructed from another set of abstractions ruled by the POE::Session architecture. A POE::Session is almost trivially defined as a map of events to the functions, class
methods Method ( grc, μέθοδος, methodos) literally means a pursuit of knowledge, investigation, mode of prosecuting such inquiry, or system. In recent centuries it more often means a prescribed process for completing a task. It may refer to: *Scien ...
, and/or object methods that handle them. POE::Session objects also contain a storage space shared by all its event handlers, called a heap. Any way you slice them the states are solidly identified and clearly defined. A more featureful
event handler In programming and software design, an event is an action or occurrence recognized by software, often originating asynchronously from the external environment, that may be handled by the software. Computer events can be generated or triggered ...
is a POE::Session subclass called POE::NFA - an event-driven
Nondeterministic finite automaton In automata theory, a finite-state machine is called a deterministic finite automaton (DFA), if * each of its transitions is ''uniquely'' determined by its source state and input symbol, and * reading an input symbol is required for each state ...
(a ''smarter'' finite state machine). This event handler moves from one strictly defined state to another as events, polls, user selections, or other external events require. This state machine acts to encapsulate a wide range of generic event driven threads allowing much tighter tracking along the execution path than the relatively informal POE::Session.


The I/O Layer

The Kernel's next requirement is for Input-Output handlers that exist in a single I/O layer called ''Wheels''. Wheels initiate actions, handle their resulting low-level events, and produce higher-level events for the sessions that use them. Wheels, like Sessions and Loops are built from a uniform set of abstractions - POE::Wheel - that sit on top of the Kernel. There are seven highly specialized and well-defined Wheels in POE's base distribution: *POE::Wheel::Run - Creates and interacts with child processes using pipe(), fork(), and sometimes exec(). Interaction is done through the child's standard input and output. *POE::Wheel::SocketFactory - A way to create client and server sockets without blocking to wait for their establishment. *POE::Wheel::Curses - A handler for non-blocking input from the
Curses A curse (also called an imprecation, malediction, execration, malison, anathema, or commination) is any expressed wish that some form of adversity or misfortune will befall or attach to one or more persons, a place, or an object. In particular ...
text interface library. CPAN components such as Curses::UI::POE and Term::Visual build upon it. *POE::Wheel::FollowTail - Tracks an ever-growing file, such as a log or a collaborative document, by keeping a handle on its tail. *POE::Wheel::ListenAccept - A subset of POE::Wheel::SocketFactory used for listening on existing server sockets and accepting connections from remote clients. *POE::Wheel::ReadLine - A non-blocking, event driven analogue to Term::ReadLine. *POE::Wheel::ReadWrite - A high-performance NBIO file handler for POE that uses POE's '' drivers'' and ''
filter Filter, filtering or filters may refer to: Science and technology Computing * Filter (higher-order function), in functional programming * Filter (software), a computer program to process a data stream * Filter (video), a software component tha ...
s'' to perform buffered read and write on
filehandle In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket. File descriptors typically have ...
s which draws on the next layer - POE's own little file system.


The file layers

Drivers do the actual work of reading and writing filehandles. They are built according to the less abstract definitions contained in the POE::Driver module. The main driver implemented at the time of this writing is POE::Driver::SysRW - a universal filehandle reader/writer designed especially for POE::Wheel::ReadWrite. The next layer, built from POE::Filter and probably the focus of most Perl Obfuscation Efficianados (see POE #POE Humor below), is the POE::Filter set: "Filters translate between raw streams and cooked chunks of tasty dada." per `sungo' *POE::Filter::Block - parses input as fixed-length blocks. On the output side, it merely passes data through unscathed. *POE::Filter::HTTPD - parses input as HTTP requests and translates them into ''HTTP::Request'' objects. On the output side, it takes ''HTTP::Response'' objects and turns them into something suitable to be sent to a web client/user-agent. *POE::Filter::Line - parses incoming streams into lines and turns outgoing lines into streams. It used to be very basic, but recent improvements have added interesting features like newline autodetection. *POE::Filter::Reference - used to send Perl structures between POE programs or between POE and other Perl programs. On the input side, frozen data (via Storable, FreezeThaw, YAML, or some other serialization mechanism) is thawed into Perl data structures. On output, references given to the filter are frozen. Data may also be compressed on request if Compress::Zlib is installed. *POE::Filter::Stream - does nothing. It merely passes data through without any change. se
POE at CPAN
for the complete list


POE Components

Several larger
packages Package may refer to: Containers or Enclosures * Packaging and labeling, enclosing or protecting products * Mail, items larger than a letter * Chip package or chip carrier * Electronic packaging, in electrical engineering * Automotive package, ...
have been written in POE according to the POE::Component documentation. These are event-driven modules, many of which act as little daemons that provide services to larger packages to which they belong. Some of them facilitate higher-level communications between modules, especially stand-alone applications that need to remain independent from the main distribution of Perl. In general, POE Components are ready-made high level procedures that perform specific large tasks. A few examples: *Component::Server::TCP - a special-purpose TCP servlet *Component::Client::TCP - a POE-aware TCP client *POE::Component::IRC - a nearly full-featured IRC client. *POE::Component::Server::IRC - an RFC 2810 to RFC 2813 compliant IRC server (under development) *POE::Component::UserBase - a user authentication and data persistence servlet. "POE Components tend to be highly reusable libraries that handle tedious tasks, freeing programmers to focus on more interesting things. This should be true for any library, though."


POE Humor

* The Acme::POE::Knee module on the
CPAN The Comprehensive Perl Archive Network (CPAN) is a repository of over 250,000 software modules and accompanying documentation for 39,000 distributions, written in the Perl programming language by over 12,000 contributors. ''CPAN'' can denote eit ...
. * A number of silly acronym expansions at the end of What POE Is.


See also

*
event-driven programming In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or message passing from other programs or thr ...
* Twisted, a comparable framework for the
Python programming language Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically-typed and garbage-collected. It supports multiple programming p ...


External links


POE Home Page
(a Wiki site) Perl modules Perl software