in reply to XP Barometer

Very nice feature!!! ::Simple snippet :)

#!/usr/bin/perl -w use strict; use LWP::Simple; use XML::Simple; my $base = 'http://www.perlmonks.org'; my $other_users = XMLin(get("$base/?node_id=15851")); foreach my $user ( @{$other_users->{user}} ) { my $xp = XMLin( get("$base/?node_id=16046&for_userid=$user->{user_id +}") )->{XP}->{level}; printf "% 2s %s\n", $xp, $user->{username}; }

Ciao, Valerio

Replies are listed 'Best First'.
Re^2: XP Barometer
by Coruscate (Sexton) on Jan 18, 2003 at 01:48 UTC

    Does this snippet work? Yes. Should it be used? Depends. Maybe if you run it at large intervals, caching the results for the time in between. I hardly doubt you need real-time verification of where you stand in the XP world. It takes N+1 hits to the site to get the data (where N=number of users logged in). Hitting the site 41 times when 40 users are logged in is not playing nice. Perhaps throwing in a 'sleep 4' in the foreach() loop would help.

    Another thread in Perl Monks Discussion very recently discussed why the site is being sluggish. The last thing we need is 20 people hitting the site 30 times every 20 seconds.

      I don't use that code, its purpose was to see what MZSanford said in his message.In real life it would have everything you described; actually it shows a simple solution to the UI problem pointed out by Wysardry.

      Anyway, I disabled nearly every nodelet from my pages to be gentle with the Monastery many months ago.

      Ciao, Valerio