#!/usr/bin/perl use strict; #my $start = (times)[0]; my $game = ""; my $num = ""; $game = $ARGV[0] or die "Usage: %lb [#scores]\n"; if ($ARGV[1] =~ /\d+/) { if ($ARGV[1] > 0) { $num = int($ARGV[1]); } else { $num = 3; } } else { $num = 3; } use LWP::Simple; my $URL = "http://marp.retrogames.com/index.cgi?mode=bot_scores&short=" . $game; my $i = 0; my $output = "Fetching the top $num scores for $game...please wait\n"; for (split(/\n/, get($URL))) { # Strips the () and the

from the whole line if ($_ =~ /^\((.*)\)

/) { my @line = split(/,/, $1); # Skip the header line if ($line[0] eq "recording_position") { next; } else { # Strip the '' from each field my $game_position = ($line[0] =~ /'(.*)'/)[0]; $game_position =~ s/L$//; # temp fix my $game_score = ($line[1] =~ /'(.*)'/)[0]; $game_score =~ s/L$//; # temp fix my $game_date = ($line[2] =~ /'(.*)'/)[0]; my $game_player = ($line[3] =~ /'(.*)'/)[0]; my (undef,undef,undef,$mday,$mon,$year,undef,undef,undef) = gmtime($game_date); $mon = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[$mon]; $year += 1900; $output .= "$game_position: $game_score ($mon $mday $year) $game_player\n"; $i++; } } if ($i == $num) { last; } } if ($i == 0) { $output = "No scores found."; } #my $end = (times)[0]; #my $time = $end - $start; #print $output . "(that took $time CPU seconds)\n"; print $output; exit 0;