Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

pm - a quick and dirty perlmonks command line searching and reference hack

by cider (Acolyte)
on Sep 26, 2001 at 22:24 UTC ( [id://114899]=sourcecode: print w/replies, xml ) Need Help??
Category: PerlMonks Related Scripts
Author/Contact Info http://compulsion.org
Description: pm is a quick and dirty generic hacked frontend to everything2 styled databases, suitable immeadiately for searching and reference usage with perlmonks.org and everything2.com related sites, accepts -dump and -random parameters hackishly, could easily be turned into a /usr/games/fortune replacement for a screensaver (xlock -mode marquee) of random perlmonks/everything2 nodes with a little output hacking. Happy hacking.
#!/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
}
  • Comment on pm - a quick and dirty perlmonks command line searching and reference hack
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://114899]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2025-06-17 02:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.