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
Yet Another Sudoku Solver
on Aug 26, 2006 at 14:31
1 reply by SubStack
This script solves any sudoku puzzle that can be solved (as far as I can tell). I started out with a simpler version that only solved easy puzzles and then retro-fitted it to solve the harder ones where the player must follow out potentially useless trails.
spamstats.pl
on Aug 25, 2006 at 22:10
1 reply by tcf03
I needed to parse logs from a barracuda spam filter so I wrote this - its fairly simple, and so far seems to be doing well - it was written for barracudas "new" logging method. The hardest part was typing in the action/reason codes.
BigDemon
on Aug 20, 2006 at 18:16
3 replies by LordScinawa
i think to use this on my little server to get up or shutdown all the other demon such as httpd,sshd,ftpd when i don't need it. i how that doing so i can evitate some attaks from extern :) in the two file there are the username and password and the command to execute with a little comment. :)
perl-assoc 0.4
on Aug 16, 2006 at 18:17
3 replies by Maze
a simple listing script for associations on a win32 system like assoc for win 2000/XP - there is now some limited support for changing extensions but it's buggy, due to the way windows behaves to third party changing of the associations - that's purely cosmetic though however there is no creating or deleting of extensions: I think this might be a bug in the TieRegistry.pm because it doesn't seem to be able to create or delete key 'default' values could be used on win 9.x or others without assoc since 0.1 added options and help and rewrote to make clearer (thanks ikegami) but for some reason looking up a specific extension has been broken... at a loss here... since: 0.2 fixed bugs - albiet a little sloppily turns out looking up specific extension was just me using = instead of ==, *slaps forhead* since: 0.25 added functionality for changing (not deleting or creating) a single association and listing more than one extension, also a foil to bail when it tries to be executed in a non win32 enviroment since: 0.3 bugfixes, code cleanup (/F switch now applies to all output) applied deletion and creation #code according to TieRegistry documentation, doesn't seem to work though
perl-assoc 0.1
on Aug 16, 2006 at 16:29
0 replies by Maze
a simple listing script for associations on a win32 system like assoc for win 2000/XP except there isn't yet any functionality to change association Just list them...quite uselessly - just proof of concept
Color diff for terminal
on Aug 12, 2006 at 08:07
0 replies by polettix
Update: there's a stripped down Perl 6 version, check it out!

This will help you browse diff-like outputs (either plain or unified) on the terminal, colorising differences. It will also be able to invoke other programs that produce diff-like output (like some commands for version control systems).

The approach is different from other colorising script-s:

  • I'm not using Algorithm::Diff, and
  • I'm using terminal colorising capabilities, not HTML
Regarding the first bullet, it's better than it may look like. To diff two files I'm either fork()-ing a diff process, or requesting you to do so, but this is intended because it allows to access (nearly) all options that diff has. Moreover, this script works with all diff-producing programs (if the format is compatible with diff, either in the "plain" style or in the "unified" one), while Algorithm::Diff would be restricted to the two-files-diffing world (more or less).

Regarding the second bullet, I needed something to quickly show me the differences on the terminal - just like diff (or cvs diff, or svk diff, or...) do, but with colors to make them outstand. The drawbacks are many, among which:

  • you have to use a terminal that works with Term::ANSIColor
  • it's mostly useless for very long diffs
Again, this was no problem for me because I have such a terminal and the diffs I check are usually less than a few (terminal) pages.

As a final note, if you have symbolic links you can get the most out of the script by:

  • installing it as colordiff somewhere inside $PATH
  • make a symbolic link to it named cdiff, again inside the $PATH
Invoking the script when it's called cdiff basically turns it into a drop-in replacement for diff(1), so that you can:
shell$ cdiff -u file1 file2 # with colors, instead of shell$ diff -u file1 file2 # without colors, or shell$ diff -u file1 file2 | colordiff # wow, way too long!
I know that this name-based behaviour change is generally frowned upon, but I think that in this case the advantage is self-evident.

Be sure to check the documentation for hints about using this with version control systems, like CVS or SVK. I hope you'll find it useful!

Subversion(SVN) pre-commit hook
on Jul 19, 2006 at 14:12
0 replies by runrig

I needed a Subversion pre-commit hook script to commit based on the name and contents of the file being committed. I found a python example, so I thought I'd try something similar in perl.

Warning: this seems to work, but I do not know if I've got the subclassing of the SVN::Delta::Editor methods correct (can't find good docs or examples). Advice is appreciated.

lspm — list names and descriptions of Perl modules in a directory
on Jul 16, 2006 at 01:48
2 replies by Aristotle

Remember pmdesc2 - lists modules with description? It’s a script that lists any or a subset of the modules you have installed, complete with the version number and a description, inspired by Tom Christiansen’s pmdesc, but without a number of its annoying flaws, with much higher speed and far cleaner code.

This time around, I added a bunch of options and DOS-newline translation to address problems brought up by Fritz Mehner. In the process, I also cleaned the code up even further and added POD and proper --help etc by way of the inimitable Pod::Usage.

Update 2006-07-16T11:03+0200: fixed a minor oopsie with --align-cont.

A complete perl roguelike
on Jul 14, 2006 at 21:28
1 reply by dabreegster
My main project for the past year has been a Perl roguelike engine. I finally produced the first game with the engine, and I'd like to hear feedback on the game and, if anybody's brave, the code. The game consists of quite a few modules, data files, and such, so I've packaged it together: http://assilem.org/breegrl/trunk/emotionrl.tgz Who knows? You might enjoy it!
ReorgXSD.pl
on Jul 11, 2006 at 05:19
1 reply by dsilvia
If you're like me, generated code is generally difficult to parse visually. I've recently been working on a project that uses XSD code generators and the output code is _very_ confusing to a novice like me. And generally, when I go to generate an XML from the XSD, it asks me questions like "whats the root element", and that's not always readily apparent. So, I dusted off my Perl (haven't used it for about 10yrs) and put together a script that reorganizes the output into something a bit more humanly decipherable. I called the script ReorgXSD.pl, but obviously you can call it whatever you like.;)

output from ReorgXSD.pl when no arguments:
Usage: ReorgXSD.pl file(s)

Reorganizes xsd files to be more human readable. Puts any header information
first, then tries to determine a root entity and places it next. Should more
than one entity be a possible root entity, all are listed, and if none are
found, a comment to that effect is entered. Next, any remaining complex
elements, then simple elements, then complex entities, and simple entities.
Last whatever is left (if any!;)

The only requirement is a well-formed file. Qualification for a root entity
is that it not be referenced by any other entity.

Results of the process are placed in a like named file with the prefix of
'ReorgXSD'.

Shortcomings:
Does not analyze DTD entries to determine proper settings for
type/attribute/ref, specifically, prefixes. It merely assumes that
any prefix ending in a colon (:) is valid an has been provided for.

Cannot distinguish between relevance of entities if they are named
alike.

Comments are not preserved as they cannot be meaningfully
interpolated. There is no way to tell if a comment goes with a
specific entity or group of entities or the whole file!:-(

The concept of non-reference indicating a root element can be
naive in the case of very complicated xsd files with imports and
other outside references.