Perl Scripts
These are some Perl scripts I've written over the years. Feel free to
download and use them, but please give me credit if you re-distribute
them. Whenever possible, please don't re-distribute directly, but just
ask people to access this page
(http://www.sarangworld.com/perlscript.html). Note that accessing the
links below will give you a listing of the program, and won't
actually run it. You will need Perl 5.001 or later to run most
scripts. Some cgi scripts in this directory will not work with the
NCSA server; we use Apache, which is how I test them. Email me if you
use NCSA and still want to use these scripts.
DISCLAIMER: These programs are not guarenteed in any form or fashion,
and may be dangerous. Any use is strictly at your own risk.
Number of lines below indicate 80-character lines, and do not include
comments or the "#!/bin/perl" line (the shell directive). More
recently-added scripts are closer to the top, and new scripts are
continously being added.
The Programs
- homepages.pl: Two-liner which
determines who on your system has homepages (usage: homepages.pl
/etc/passwd). Works under certain assumptions, including that your
system uses the public_html protocol.
- sites2.pl: Three-liner parsing a
web-access log (use: sites2.pl {logfile}) to determine which sites hit
your pages, in order of frequency.
- countess.xbm: 24-line server-level
counter I use on my pages, documented somewhat via comments. I didn't
write this (it was originally called "count.xbm", but I changed it to work on the server-level and hacked it
down to 24 lines.
- webserv.pl: Use "webserv.pl
{directory} {portnum}" on a machine to start a webserver on port
number 'portnum', where 'directory' is the full path to the directory
you wish to serve (for example "webserv.pl
/home/user/YOURNAME/public_html 4242"). People can then access files
in your directory via "http://machinename:PORT/filename.html". Note
that this three-liner is minimal, and does NOT support: auto-indexing,
CGI, SSI, forms/posting, https, htaccess, plus others. Essentially it
only supports 'GET', and is intended just as a curiousity.
- newstree.pl: A long (11-line) script
that does rudimentary threaded news reading. This program only works
if the news directory is hosted on the same machine the script is
run.
- htmlone3.pl: Given a file containing
URLs, this five-liner returns all links (one level deep) on the
specified URLs (note: must be a file or URLs, not a URL itself
on the command line).
- graball.pl: Given a file containing
URLs, this one-liner copies the URLs to the local disk. Can be used in
conjunction with htmlone3.pl to suck all the information off a page.
- pages3.pl: Six-liner that parses a web
access logfile, and returns hits per page, and total bytes transferred.
- fakessi.pl: This three-liner parses
its argument as an 'shtml' file, faking server-side includes. For
example, this file turns into this
file. Since this system supports server-side includes, anyway,
it's not particularly useful here; however, it might be useful on
systems that don't intrinsically support SSI.
- search.pl: This four-liner searches your web
pages for a given word.
- htmldescend.pl: A six-line
script that checks for broken links in one on more HTML files.
- perky2: One-liner that maps its first
argument across its second. For example, 'perky2 "mv # #.bak" *' would
add a .bak extension to all your files. This is the first Unix program
I ever wrote, originally in Bourne-shell (it didn't quite work right),
then in C. When I rewrote it in C++, it grew from
20K to over 100K. My first attempt in Perl was 105 bytes, and this
version is 89 bytes.
- readdbm: One-liner to read a DBM file.
- writedbm: Two-liner to write a DBM
file, given the output of readdbm.
Last modified stardate: 20070609.123522
Featured links:
Please report any errors, comments, questions, suggestions, etc... to:
Sarang (webmaster@sarangworld.com). Thank you!
Please do not email this address: 00000000-48c16c9d@st.sitesuck.com
Search SarangWorld
SarangWorld Home Page