#!/usr/bin/perl # # search - a quick and dirty hack to search an everything2 based # database /fast/ using a text browser of your choice, suitable # immeadiately for everything2 and perlmonks # cider@compulsion.org 09.25.2001 || http://compulsion.org # # you either want this to say... $browser = "w3m"; # w3m is pretty. # or comment out the above and uncomment the following line.. # $browser = "lynx -cookies"; # lynx is more defacto std. # this can either be perlmonks.org, or everything2.com based.. $site = "www.perlmonks.org"; # your luck may differ with anything else # accepts -dump and -random parameters (also hackishly)... could easily # be turned into a /usr/games/fortune replacement for a screensaver # (marquee) of random perlmonks/everything2 nodes with a little output # hacking. $|++; # unbuffered io hack foreach $arg (@ARGV) { if ($arg !~ /-dump|-random/) { $string = $string . "%20" . "$arg" } elsif ($arg =~ /-dump/) { $dump = 1; } elsif ($arg =~ /-random/) { $random = 1; } }# parsing hack $string =~ s/^\%20//g; # hack to hack the parsing hack $dstring = "$string"; $dstring =~ s/%20/ /g; print "Searching for $site::$dstring...\n"; # display the goods print "Dumping output to stdout...\n" if ($dump eq 1); print "Random node...\n" if ($random eq 1); #system "sleep 1"; # be lazy if ($random eq 1) { if ($dump eq 1) { open WEBDUMP, "$browser -dump \"http://$site/index.pl?op=randomnode\" |"; while() { unless (/[0-9]{1,3}\. http|^References/) { s/\[.*?\]//g; # remove the [number] link references. print "$_"; } } close WEBDUMP; die "\n"; } system "$browser \"http://$site/index.pl?op=randomnode\""; # leave } else { if ($dump eq 1) { print "running: $browser -dump \"http://$site/index.pl?node=$string\" |\n"; open DUMP, "$browser -dump \"http://$site/index.pl?node=$string\" |"; while() { unless (/[0-9]{1,3}\. http|^References/) { s/\[.*?\]//g; # remove the [number] link references. print "$_"; } } close DUMP; die "\n"; } system "$browser \"http://$site/index.pl?node=$string\""; # leave }