In my day-to-day life, I end up writing a lot of little Perl scripts to solve various problems I have. Often I've been asked for a copy of these either for someone learning Perl or just someone who has a similar problem they want to solve. Well, here you go, an index of Perl scripts I have on this site.
Now be warned, I'm more a sysadmin than a programmer, and there are a million better Perl programmers than I, so no need to alert me to any failing in my programming style, I already know about it :) If you have any other questions or comments feel free to email me at greenfly@greenfly.org.
Text Parsers
- 911Reportparse -- Converts the 911 Commission's PDF report (or .txt file converted by pdftotext) and splits it into text chapters
- backtick_wrap -- This script will take any input line containing items in the FIRST pair of parenthesis and wrap each item in backticks, so for instance:
(foo, bar, baz, quux) xyzzy (foobar, barbaz, quuux)
becomes:
(`foo`, `bar`, `baz`, `quux`) xyzzy (foobar, barbaz, quuux)
notice the items in the second pair of parens are unaffected
- comment_grep -- This script greps out "C-style" comments from a file, ie /* */ or // comments.
- filesubset -- This program randomly chooses a subset of the lines in a file given as input, and outputs those lines to the screen.
- grab-minmax-latlong.pl -- Given a .gps file, this script will output the min and max latitude and longitude in the file, useful when you want to get a map that covers the full area.
- omg-color -- Script which colorizes input piped to it according to a specified pattern. Especially useful for Gentoo users.
- xmms2rhythmbox -- Probably deprecated by now, this script will take a standard xmms playlist as input and output a rhythmbox-compliant playlist
Web Scrapers
- arsforum_user_grab -- Grabs all the currently-participating users in a particular Ars Technica Forum
- country_code -- Grabs the current list of country codes from the IANA and prints them out. Useful for finding out what that two-letter country code means.
- fedex -- The basis of my track script, this script just tracks fedex packages. Use track instead.
- gtk2_terrar.tar.gz -- My GTK2-Perl Dept. of Homeland Security terror level script.
- itr -- A script I use in IRC to output a quick one-line status from www.internettrafficreport.com.
- itr2 -- An advanced version of the previous script, this version is intended to be left running in a terminal, and updates the status of www.internettrafficreport.com and outputs it in a multi-color, multi-line format.
- kernel-check -- Not exactly a proper scraper (as it uses an FTP library), this script will check for the latest file in a specified directory (or file glob) on any number of ftp servers. By default it scans for the latest kernel
- parse_table -- This basic script illustrates how to use the HTML::Parser Perl module to parse a table.
- rss-arsforum -- This script scrapes the index page from a specified Ars Forum (defaults to Linux Kung Fu) and outputs an rss file based on it.
- tk_terrar2.tar.gz -- My Perl-Tk Dept. of Homeland Security terror level script.
- track -- A perl script that can accept a number of FedEx and UPS tracking numbers and track them, printing the output (now can output to RSS).
- terrar -- A simple bash script that will grab the current terror level from the Dept. of Homeland Security.
- weather -- A simple weather script that uses Weather::Cached to access weather.com. It pulls down the weather for the list of cities in weather.txt and generates a basic .html file with the contents--useful for server-side includes.
CGIs
- cal.cgi -- An example of the cal.txt script in action
- cal.txt -- A very simplistic HTML calendar-generating perl function.
- spamnames.cgi -- A script that generates a random first and last name from extracted From: headers inside my Spam folder. The code is here.
- timeclock.cgi -- A simplistic timeclock CGI. The code is at timeclock.txt.
Filesystem Tools
- auto.smbbrowse -- An autofs script that lets you browse through a filesystem labeled after SMB machine names that are dynamically scanned for as you browse
- dot2homeetc -- This script moves all your local dotfiles into a ~/etc directory for easier management, and then symlinks the old locations so programs that rely on them still work. See homeetc2dot to convert back.
- homeetc2dot -- The "undo" for my dot2homeetc script, this converts a ~/etc directory back to dotfiles.
- maildirs -- Not a script I wrote, this is a script to generate a single list of Maildir folders below a specific directory
- rename -- Another script I didn't write, but incredibly useful. Included with most Perl installs nowadays, this script lets you pass a regular expression to apply to filenames you pass as arguments. So for instance to change foo to bar in a group of filenames you would type
- sd2usbguid -- The complement to my usbguid2sd script, this function gets passed the a scsi hard drive device and returns the GUID assigned to it from /proc/scsi/usb-storage-0/.
- usbguid2sd -- The complement to my sd2usbguid script, this function gets passed the $PRODUCT environment variable for a usb device, and returns which scsi hard drive that GUID was assigned to
rename 's/foo/bar/g' *
Misc
- caffeine_level -- This script I run inside my IRC client and pass a number to print out my current caffeine level, 1 to 10.
- cng_mac -- Not a script I wrote, but useful nonetheless, this script generates a random MAC address that looks "real"
- flag-folder -- A simple shell script that searches for all 'Flagged' email in a Maildir and symlinks them inside a "flagged" folder so you can see all of your flagged messages at a glance
- focus_watch -- This eesh script takes the name of a window as an argument (eesh -ewait 'window_list' will show all the window names) and watches that window for focus. When it has focus it is unshaded, and when it is unfocused it shades the window again. Note that this script only works for the Enlightenment window manager.
- panel_mailcheck_remote -- This script runs fetchmail to check for new email on a remote server, then executes offlineimap to sync the email with a local directory if new mail exists.
- panel_mailcheck -- The local counterpart to panel_mailcheck_remote, this script monitors the local maildirs for new mail, and then runs apanelc (a program for my laptop that can toggle and blink a status LED on my display) based on new mail existing.
- id32m3u -- This script reads the id3 tags of any MP3s it finds in the directories it is passed, and then creates a Playlist directory containing m3u files in an Artist and Album structure.
- mencoder -- This shell script automates 3-pass encoding for mencoder directly from the CD. Edit the environment variables to taste, of course.
- mencodercat -- Like the previous script, this automates 3-pass encoding, but in the case that the .vob files have already been ripped to disk.
- random-date-gen -- This script generates a random date given a range of years.
- spamgraph -- Reads the SpamAssassin score for every message in a maildir or mbox, and then generates a .png graph plotting score vs. # of messages.
- stayalive.pl -- A quick script I wrote to keep my DSL modem power cycled using X10 devices. It pings the gateway and if it's down, it sshs into the machine with the X10 device and runs br to power cycle the modem.
- truck_ets -- A simple script that keeps track of when Anthony can leave the Army.
- whiptag -- A simple script that keeps track of when whiprush's tags expire.
- wifi_mapping.pl -- An untested (by me) script that allows you to specify a prioritized list of wireless access points to connect to, and it will scan for any current APs and output the one of highest priority, or "any" if none are found.