#!/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 easil
+y
# 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(<WEBDUMP>) {
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(<DUMP>) {
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
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.