http://www.perlmonks.org?node_id=424550

#!/usr/bin/perl use strict; #use warnings; #use diagnostics; use CGI; my $query = new CGI; print $query->header(); use IO::Socket::INET; print "<main>"; print "<title> UPS Status </title>"; my $sock = new IO::Socket::INET->new(PeerPort=>20100, Proto=>'udp', PeerAddr=>'207.210.215.108') or die "something we +nt wrong: $! "; my $request = "\xff\xff\xff\xff\x67\x65\x74\x69\x6e\x66\x6f\x20\x78\x7 +8\x78"; $sock->send($request); my $text; $sock->recv($text,235); my ($maxclients, $clients, $gametype, $mapname, $needpass); $text =~ s/\\/ /g; my @data = split(' ', $text); my $count = 0; foreach (@data) { chomp; if ($_ =~ m/sv_maxclients/) { print "<maxclients> $data[($count+1)] </maxclients>"; } if ($_ =~ m/clients/ && !($_ = m/sv_maxclients/)) { print "<players> $data[($count+1)] </players>"; } if ($_ =~ m/gametype/) { print "<gametype> $data[($count+1)] </gametype>"; } if ($_ =~ m/mapname/) { print "<mapname> $data[($count+1)] </mapname>"; } if ($_ =~ m/needpass/) { print "<needpass> $data[($count+1)] </needpass>"; } $count++; } print "</main>";