#!/usr/bin/perl use strict; use warnings; use LWP; use XML::Simple; use Daemon; use Tk; my $obj=new Daemon; $obj->Daemonize; my $oldxp=0; my $curxp; my $user="lakshmananindia"; while (1) { if ( -e "./.perlmonks" ) { open (FILE,"./.perlmonks") or die "Cannot open the file .perlmonks\n"; $oldxp=; chomp $oldxp; close FILE; } my $browser = LWP::UserAgent->new; my $req="http://perlmonks.org/index.pl?node_id=16046&for_user=" . $user; my $response = $browser->get($req); my $ticker = XMLin($response->content); $curxp = $ticker->{XP}->{xp}; my $gained = $curxp - $oldxp; my $mw = new MainWindow; $mw->withdraw(); if($gained > 0) { $mw->messageBox(-icon => 'info', -message =>"Hey $user! You gained $gained XP\n", -title => "Your current XP is $curxp", -type => 'ok'); } elsif($gained < 0) { $mw->messageBox(-icon => 'info', -message =>"Sorry $user! You lost $gained XP\n", -title => "Your current XP is $curxp", -type => 'ok'); } else { $mw->messageBox(-icon => 'info', -message =>"Hai $user! Your XP is $curxp\n", -title => "Your current XP is $curxp", -type => 'ok'); } $mw->destroy(); open (FILE,'>',"./.perlmonks") or die "Cannot open the file\n"; print FILE $curxp; close FILE; sleep(300); }