Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Terminal Chatterbox Viewer

by krujos (Curate)
on Jan 28, 2003 at 03:22 UTC ( #230472=snippet: print w/replies, xml ) Need Help??
Description: This is a small chatterbox watcher. It keeps me in the know when I run from machine to machine. It beeps everytime there is a new message, be warned, if you have a loud bell this can get annoying.
#!/usr/bin/perl
use warnings;
use strict;
use XML::Simple; 
use LWP::Simple;

my ($url, $ref);
my $lastMsgTime=0;

while (1) { 
        #Get the latest chatterbox contents. 
    $url = get("http://www.perlmonks.org/index.pl?node_id=15834");
        #Parse it.
    $ref = XMLin($url, forcearray=>1);
        #Print the contents.  
    foreach my $msg (@{$ref->{message}}) { 
        if ( $lastMsgTime < $msg->{time}) { 
            #this has a new line so the users name is above thier text
            print "$msg->{author}: $msg->{content}\n\n"; 
            $lastMsgTime = $msg->{time};
            print "\a";
        }
    }
    $ref=undef;
    sleep 30;
}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://230472]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2017-11-21 00:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (294 votes). Check out past polls.

    Notices?