#!/usr/bin/perl -w use strict; use IO::Socket; use Time::HiRes qw(tv_interval gettimeofday); my $DEF_PORT = 27015; my ($host, $name, $map, $active, $max, $ping, $port); format SERVER = @<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<< + @<<< $host, $name, $map, $active . '/' . $max, $ping . $~ = "SERVER"; my @servers; die "invalid usage" unless $ARGV[0]; if ($ARGV[0] eq '-f') { open(CONFIG, "<$ARGV[1]") or die "can't open $ARGV[1]: $!"; while (<CONFIG>) { chomp; ($host, $port) = split; push(@servers, [$host, ($port or $DEF_PORT)]); } close(CONFIG); } elsif ($ARGV[0]) { push(@servers, [$ARGV[0], ($ARGV[1] or $DEF_PORT)]); } foreach my $server (@servers) { my $sock = IO::Socket::INET->new(PeerAddr => $server->[0], PeerPort => $server->[1], Proto => 'udp'); unless ($sock) { warn("could not connect to ", join(':', $server->[0], $server->[1]), " ($!)"); next; } output_info($sock); $sock->close(); } sub hl_send { my $sock = shift(); my $cmd = shift(); print $sock pack("NZ*C", -1, $cmd, 0); } sub hl_recv { my $sock = shift(); my $recv = undef; recv($sock, $recv, 1024, 0); return $recv; } sub output_info { my $sock = shift(); my $t0 = [gettimeofday()]; hl_send($sock, "info"); my $recv = hl_recv($sock); unless (length($recv)) { warn "problem fetching data from remote host"; return; } $ping = tv_interval($t0); $ping = sprintf("%.0d", 1000 * $ping); my @junk; (@junk[0..4], $host, $name, $map, @junk[5..6], $active, $max, $jun +k[7]) = unpack("C5Z*Z*Z*Z*Z*CCC", $recv); $name =~ s/ /_/; write(); }

In reply to css: Counter Strike Scanner by skyknight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.