Reviewing the hlv Script Step by Step
The script starts with the declarations of the libraries we’re going to use, along with some constants:
use Tk; use Net::Jabber qw(Client); use strict; use constant SERVER => 'gnu.pipetree.com'; use constant PORT => 5222; use constant USER => 'dj'; use constant PASSWORD => 'secret'; use constant RESOURCE => 'hlv'; use constant BROWSER => '/usr/bin/konqueror';
The hlv script will connect to Jabber as a client, so we need to specify that
in the use statement to have the appropriate
Net::Jabber modules loaded. We’re going to be
connecting to the Jabber server at gnu.pipetree.com,
although, as we said, the RSS news agent might live somewhere else. It
just so happens that in this scenario, there’s a reference to the component
in gnu.pipetree.com’s JSM
<browse/> section, so we can
carry out registration conversations with it (using JIM, for example).
If the Fetch button is clicked when an item in the
list is selected (see Figure 9-10), we want to
jump to the story by launching a web browser. The constant
BROWSER used here refers to the browser—in this case, Konqueror, the browser of choice for KDE users—on the
local machine.
my @headlines; my @list;
We declare two arrays: @headlines, which we’ll use
to hold the items as they arrive contained in the headline
<message/> elements on the XML stream,
and @list, to hold the URLs that relate to those
items in @headlines.
After connecting to and authenticating with the Jabber server, we set up the callback ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access