toy for the website

Nicholas Clark nick at ccl4.org
Fri Feb 9 18:20:10 CST 2001


I've got a some content for the website.
Bath.pm has the clickable world map of pms
I've written a script to turn the XML into a label file for xearth.
My X root window is now a globe with perl monger groups pointed out.
[we're not on their because that XML file doesn't have our lat/long in it
yet. It also seems to let us change the list owner separately from the
tsar. Maybe this is how we can do it]

grab standard out from following to file, say pm.xearth. Then

xearth -markerfile pm.xearth

et voila (after a wait)

Version 2 will optionally use LWP to get the XML from the mothership at
www.pm.org

Nick

#!/usr/bin/perl -w
# Version 0.01
# <nick at talking.bollo.cx>
use strict;
use XML::Simple;

# Make missing lat/long !exist with suppressempty
my $ref = XMLin ((shift || '-'), suppressempty => 1);
my $groups = $ref->{group};

foreach my $name (sort keys %$groups) {
  my ($lat, $long) = @{$groups->{$name}{location}}{"latitude", "longitude"};
  my $id = $groups->{$name}{id};
  if (!defined $lat or !defined $long) {
    print "# $name ($id) has no ICBM block :-(\n";
  } else {
    my $bad_coord;
    if ($lat =~ tr/-0-9.//c) {
      warn "malformed latitude for $name: $lat";
      $bad_coord = 1;
    }
    if ($long =~ tr/-0-9.//c) {
      warn "malformed longitude for $name: $long";
      $bad_coord = 1;
    }
    if ($name =~ tr/\0-\37\"//) {
      warn "worrying $name";
      $bad_coord = 1;
    }
    if ($bad_coord) {
      print "# $name ($id) has mangled ICBM block lat=$lat long=$long\n";
    } else {
      $name =~ s/&aacute;/á/g; # Hmm. What's the simplest module to get these
      $name =~ s/&eacute;/é/g; # correct?
      $name = "\"$name\"" if $name =~ tr/-0-9A-Za-z.//c;
      print "$lat\t$long\t$name\t# $id\n";
    }
  }
}



More information about the Tyneside-pm mailing list