This section is now closed for posting code. Please use Cool Uses For Perl instead.

Code Categories
Audio Related ProgramsFTP stuffNT Admin
CGI ProgrammingFun StuffWin32 Stuff
Chatterbox ClientsGUI ProgrammingMiscellaneous
CryptographyHTML UtilityText Processing
Database ProgrammingUtility ScriptsNetworking Code
E-Mail ProgramsWeb StuffPerlMonks Related Scripts


New Code
Tk Photo Slideshow, with scrolling and scaling
on Oct 18, 2006 at 13:47
1 reply by jdporter

This is meant primarily to illustrate how to load and display photo images in Perl-Tk. Secondarily, it shows how to scale images, how to put images into a scrolling window, and how to "drag" such a image.

Usage: slideshow.pl [DIRECTORY]

If no directory is specified, it uses the current directory.

Currently, it obtains a list of all jpeg files (specifically, files matching *.jpg) in the directory and shows them in slideshow. Use PageUp/PageDown, Left/Right, and Up/Down to go to the previous/next image in the list. The list circles around at both ends.

To drag the image (only possible when scrollbar(s) present), press down the main mouse button somewhere on the image, move the mouse, and let up the button.

Module Finder
on Oct 18, 2006 at 11:10
1 reply by innominate
I've been having problems with some cpan installs. You know the deal. They install and test correctly, but something just doesn't work right. *cough* Needs more testing! *cough*

So, in my haste to track down a few of these bugs, I wanted to know where the module(s) were stored. I threw together an extremely simple, but rather useful little script. (It was originally a one-liner, hence the anon sub and the speedy ternary conditional.)

It's definately not fancy, but it does its job gracefully.

IMO It's pretty self explanitory, but the jist is that it does a simple ignore-case regex over all dirs and subdirs in @INC. When it gets a hit, it spits it out.

(Edited to clean up formatting!)
pexec.pl: snippet runner
on Oct 14, 2006 at 16:30
2 replies by Hue-Bond

I'm very lazy. When I'm at the monastery, I hate to open an $EDITOR just for pasting that small snippet, saving it to a file ("Overwrite?" yes, of course) and then run it. So what I usually do is run perl at the shell prompt, and paste there. This has the drawback that, to modify it, I have to copy-paste part of it, change something and copy-paste the rest. And when the output of the program is so large that my terminal runs out of buffer space, it is lost. These problems notwithstanding, I'm very fond of this way of doing things since that's how I began using Perl. Just type, do a Ctrl-D and see the action!

This Gtk2 program has a text box in it, and a "Run" button. Just paste the code there, and click the button (or hit Alt-R). The output of the code goes to pexec.pl's STDOUT, so it has to be executed from a terminal. Snippets are run under -t to encourage good programming habits without standing in the way.

linked-port: find given linked libraries ("shared objects") in FreeBSD Ports
on Oct 14, 2006 at 03:34
0 replies by parv

This is a preliminary version -- with/ output via Data::Dumper and lacking POD (: "it's all in code", see region around GetOptions()) -- to find linked libraries in files related to FreeBSD ports.

This came about due to recent OpenSSL security advisories, necessitating rebuild of ports which were linked to old libraries. Dmitry Marakasov in message <20060907181108.GB90551@hades.panopticon> on freebsd-ports mailing posted ...

for port in `pkg_info -oaq`; do grep OPENSSL /usr/ports/$port/Makefile >/dev/null && echo $port; done

... which seemed not very reliable as that would miss any port which does not have "OPENSSL" in its Makefile. "security/nss" is such a port used by Firefox. So, I decided to just use ldd(1) directly on the files installed ...

# listpkg (used in filepkg): http://www103.pair.com/parv/comp/src/per +l/listpkg-0.22 # filepkg: http://www103.pair.com/parv/comp/src/sh/filepkg filepkg . | egrep '^/.*(bin|libexec)' \ | xargs -I % ldd % 2>/dev/null | less -p'(crypto|ssl)'

... output of which was rather tiresome to search through, and that was enough to open up my $EDITOR & flex some perly muscle.

Attachment Search for TWiki
on Oct 11, 2006 at 11:43
0 replies by Melly

We have several internal twikis, and one of the problems we are now dealing with is that users have been uploading word documents and other attachments without describing them on a twiki page, or adding suitable key-words.

The consequence is that we often can't find useful docs since twiki doesn't search attachments... so I wrote this program to allow users to search inside attachments (or just their filenames) for useful content.

A few parameters need setting in the code, but hopefully they are clear enough as to what values they need (basically, $searchpath, $doc_url, $twiki_url, $return_url and @twikis). One final note - if you want the option to search all Twikis, make 'All' the first elemement of @twikis, otherwise leave it out.

I suspect that the code would run against other wikis as well, but I haven't tested.

Runs under warn and taint without problems.

file-search: File search with minimum horizontal scrolling of output
on Oct 08, 2006 at 00:51
0 replies by parv

(From POD) The main reason for existence of this program is to minimize horizontal scrolling by displaying the file name only once (on a line of its own) before display of the lines matched, and by collapsing tabs and multiple spaces. Other reasons are to strip the current directory from the file name paths, and to have matched text highlighted.

Updated version can be found in http://www103.pair.com/parv/comp/src/perl/ as file-search-\d+[.]\d{2}

Zedulator - a tiled, integrated CB/PM/Web client
on Oct 03, 2006 at 14:22
0 replies by jZed
Zedulator is a chatterbox client that allows you to explore links mentioned in the chatterbox or entered in the search in the same window as the chatterbox. It requires only a javascript-enabled web browser to run, supports Perlmonks and customizable search shortcuts, and provides more control over screen layout than fullpage chat. You can see 309074 and 575798 for previous discussions about Zedulator.

Installation

  1. Download the code, naming it "zedulator.install.pl"
  2. CD to wherever you saved it, run "perl zedulator.install.pl"
  3. When prompted, enter a pmurl or none for www.perlmonks.org
    four .html files will then be created
  4. Point your browser at zedulator.html and away you go.
    You can erase zedulator.install.pl if you want to.
Run zedulator and read it's online hlep for more details.
Guest Cleanup
on Sep 30, 2006 at 12:53
3 replies by Maze

this little script assumes that you have a /home/guest directory and a /home/default directory

it cleans out the /home/guest directory and saves the content of various directories under a time-stamped folder, it then mirrors the /home/default directory in the /home/guest and sets the appropriate modes,uid's and gid's.

Latin Verb Conjugator
on Sep 21, 2006 at 21:58
1 reply by Minimiscience
As stated in the comments, this script will create a synopsis of a Latin verb in a specified person & number and will output the results as a LaTeX document. This script will work only for regular verbs and does not yet support deponents. You will need pdflatex and general knowledge of LaTeX accents to use it; without the former, you should edit the last four lines or so of the script. Without the latter, I pity you.
BinBot - Find .NZB links in RSS feeds.
on Sep 20, 2006 at 23:40
0 replies by iamjafi
This is a short program that I wrote to help me keep track of what .NZB files are available on various USENET search websites. The program grabs the RSS feeds from various sites and compares their contents to a list of keywords. Any matching entries are written to a new RSS file stored locally on my computer.

Update: 9/24/06 - I found an RSS feed that requires gzip compression. Since LWP::Simple doesn't support gzip, I have changed the code to use URI::Fetch instead. Thanks to wolv's comment here.