#!/usr/bin/perl # # favmame.pl David Mcanulty 10/08/04 # perl program that sends your rom name to a webserver so others can see # what the current/last game you played was. You could also chomp data on # server and make a top 10 favorites, etc, etc. # $debug=1; #html header print "Content-type: text/html\n\n"; # Get game from html form use CGI; $query=new CGI; $game=$query->param('game'); chomp($game); $game =~ s/.rom//ig; print "($game)\n" if $debug; @database = `cat mame.map`; foreach $line (@database) { $line =~ s/\(//ig; #get rid of revision info from rom desc, who cares $line =~ s/\)//ig; #get rid of revision info from rom desc, who cares ($rom, $desc) = split(/ /, $line, 2); chomp($rom); chomp($desc); if ($game eq $rom) { print "rom: $rom\n desc: $desc\n" if $debug; $output1 = $desc; $output2 = $rom; } } if (($output1) && ($output2)) { open(LASTGAME,">favmame.html") || die "Couldn't open favmame.html for output: $!"; open(LASTROM,">favmame.rom") || die "Couldn't open favmame.html for output: $!"; open(LOG,">>favmame.log") || die "Couldn't open favmame.log for output: $!"; chomp($output1); print LASTGAME "$output1\n"; chomp($output2); print LASTROM "$output2"; print LOG "$output1 $output2\n"; close LOG; close LASTGAME; close LASTROM; } else { print "rom $game wasn't found in my mame.map file, not logging.\n"; }