#! /usr/bin/perl # srom: Sucks-Rules-O-Meter # # Copyright 1998 Electric Lichen L.L.C. # Don Marti # revised 3 June 1999 -- new AltaVista result page format # revised 19 Mar 1998 -- added $rule_offset # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. require 5.004; use LWP::Simple; my $SEARCH_PREFIX = qq{http://altavista.digital.com/cgi-bin/query?pg=q&what=web&kl=XX&q=%2B%22}; my $SEARCH_SUFFIX = '%22'; my %aliases = ('AmigaOS' => ['AmigaOS'], 'BeOS' => ['BeOS'], 'FreeBSD' => ['FreeBSD'], 'Linux' => ['Linux'], 'Mac OS' => ['Mac OS', 'MacOS'], 'NetBSD' => ['NetBSD'], 'OS/2' => ['OS/2'], 'OS/400' => ['OS/400'], 'Solaris' => ['Solaris'], 'Unix' => ['Unix'], 'VMS' => ['VMS', 'OpenVMS'], 'Windows' => ['Windows'] ); my %synonyms = ('sucks' => ['sucks'], 'rules' => ['rules', 'rocks'] ); ########################################################################### $greatest = 1; foreach my $os (keys(%aliases)) { foreach my $alias (@{$aliases{$os}}) { foreach $quality ('sucks', 'rules') { foreach my $synonym (@{$synonyms{$quality}}) { if (get($SEARCH_PREFIX . lc("$alias +$synonym") . $SEARCH_SUFFIX) =~ /found\D+(\d+)\D+web/i) { $count{$os}{$quality} += $1 + 0; print STDERR "$alias $synonym ($os $quality): $1\n"; } } $greatest = $count{$os}{$quality} if $count{$os}{$quality} > $greatest; } } print "\n"; } die "bad AltaVista, bad, bad " if $greatest == 1; # print comment for srom2gif... print ""; print qq{}; print qq{\n}; foreach my $os (sort(keys(%aliases))) { my $suckage = int (100* $count{$os}{'sucks'}/$greatest); my $suck_offset = 100 - $suckage; my $ruleage = int (100* $count{$os}{'rules'}/$greatest); my $rule_offset = 100 - $ruleage; print qq{\n}; print '"; print '"; } print "
 sucks rules, rocks
$os'; print qq{}; print qq{"; print qq{
}; if ($suck_offset >= 75) { print qq{}, $count{$os}{'sucks'} + 0, qq{}; } else { print " "; } print "}; if ($suckage > 25) { print qq{$count{$os}{'sucks'}}; } elsif ($suckage == 0) { } else { print " "; } print "
'; print qq{}; print qq{"; print qq{
}; if ($ruleage >= 25) { print qq{$count{$os}{'rules'}}; } elsif ($ruleage == 0) { } else { print " "; } print "}; if ($ruleage < 25) { print qq{$count{$os}{'rules'}}; } else { print " "; } print "
"; my $date = scalar(gmtime(time())); print qq{

Updated $date GMT.

}; exit 0;