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
ANSI highlighting of sdiff output
on Sep 17, 2007 at 15:09
0 replies by diotalevi
Takes sdiff output and adds highlighting - red for deletions, yellow for changes, green for additions.

The default pivot for sdiff is column 65 because of its default width of 130 characters. You'll want to adjust the --pivot parameter to match your sdiff.

There's no smarts in here about tabs. Use sdiff's -t option to print only spaces.

Threaded forum with single DB table
on Sep 08, 2007 at 04:37
0 replies by Your Mother
While this is a demo, it works and shows how to add lineage to a single table as well as recursively call it in TT2. There is a module + a cgi that uses it. There is a bit of POD with the cgi. (Update: cleaned up lines/comments in a couple places; and now with fewer Toolkites! Update: 22 July 2008, updated Pod a bit.)
tblSync
on Sep 06, 2007 at 14:25
1 reply by tcf03
syncs database tables. My main use is to sync Informix tables and MS SQL Server tables.
ini file looks like this:
[configs] ; can we perform deletes in this table? deletes = 0 ; 0 for no / 1 for yes [columns] ;Remote(MSSQL) Local(INFORMIX) IDCode =id_code FirstName =first_name MiddleInitial = mid_init Lastname = last_name Address = address Address2 = address2 Address3 = address3 City = city State = state ZipCode = zip Country = country BirthDate = birth_date [keys] rkey = IDCode lkey = id_code [tables] rtable = Employee_ID ltable = empview [defaults]
Find the pivot point for sdiff output
on Aug 30, 2007 at 13:16
0 replies by diotalevi
I've got piles of log files which also contain sdiff output. The width of the sdiff output is allowed to vary so I needed a program which could examine these files and find the pivot points. This is useful later if I want to find the sdiff markup and do highlighting or stuff.
Music-Player
on Aug 29, 2007 at 15:34
1 reply by Perforin
Little script which plays mp3,wav,wma and midi files!
Subnet Overlap
on Aug 20, 2007 at 23:50
3 replies by bfarley
Analyzes tab-delimited file with network blocks for duplicates and subnet overlaps. Created for use with CISCO SESM, but could be used with any application that uses stored network blocks.
podinherit - Imports pod from superclasses
on Aug 20, 2007 at 14:34
2 replies by rvosa

DESCRIPTION

When object-oriented perl classes use inheritance, child classes will have additional methods not immediately apparent to users unfamiliar to effectively navigating perldoc and inheritance trees. For example, IO::File inherits from IO::Handle, and so an IO::File object "does" anything an IO::Handle object does.

Novice users are sometimes confused by this, and think that APIs are more limited than they really are (on a personal note: I found this to be the case when bug reports came in that some object no longer had the "set_name" method, when really I had re-factored it into a superclass).

This script remedies that by analyzing a class (provided on the command line), recursing up the class's inheritance tree, collecting the methods in the superclasses and importing the pod for the methods in those superclasses. The resulting concatenated pod is written to STDOUT. That output can then be re-directed to a file, or formatted, e.g. by doing:
podinherit -class Some::Class | pod2text | more
Module authors might use this script during the packaging of their release by doing something like:
podinherit -class Some::Class >> Some/Class.pm

IMPLEMENTATION

This script contains a subclass of Pod::Parser, which implements a stream parser for pod. The appropriate documentation for superclass methods is identified by the "command" method, which takes the following arguments:
my ( $parser, $command, $paragraph, $line_num ) = @_;
To recognize pod, the method name needs to be part of a $paragraph start token, e.g. to find pod for 'method', permutations of the following will be recognized:
=item method =head1 method() =item method( $arg ) =item $obj->method( $arg )
Or, specifically, anything that matches:
/^(?:\$\w+->)?$method(?:\(|\b)/
I.e. an optional object reference with method arrow ($self->), a method name, and an optional opening parenthesis or token delimiter \b, to be matched against the $paragraph argument to the C<command> call in subclasses of Pod::Parser.
scissors - divide an image in sub-images for easy printing
on Aug 02, 2007 at 10:45
0 replies by polettix
This script helps in dividing an image into blocks that can be easily printed on a normal printer instead of an A0 plotter. Input images are divided into tiles whose dimensions can be established quite easily and flexibly. You can access the full documentation using the --man option.
A better rand() for Win32
on Jul 30, 2007 at 14:08
2 replies by bitshiftleft
With better random number generators in the unix environments (/dev/random). I was looking for something like it on Win32, and there is. My motive is that I think some games that base there learning on neural nets may be learning on the poor periodic rand() type of random number generation. This means that the Neural Net may be learning the next roll of the dice rather than the game strategy itself. The Perl rand() repeats every 32000 times. Cryptographically generated random numbers gather entropy to seed there generators.
Lookee - Streaming graph for a console
on Jul 30, 2007 at 08:58
0 replies by diotalevi

I use this as the front end component of a graphical "top" command. Its purpose is to read some numbers in columns from STDIN and make a little scrolling graph out of it. Every line in the output is a line of data - the columns are the scale 0 to whatever the column's maximum is. The program accepts 1 or more pairs of keyword and scale.

I feed the columns Blocks In/Out, User/System/IO/Idle CPU from vmstat into it with the following script:

#!/bin/sh vmstat -n 1 | perl -lane 'INIT{$,=q[ ];$|=1}print @F[8,9,12..15]' | lo +okee in 6000 out 6000 u 100 s 100 i 100 w 100
wutu i
wut i
wut i
wst i
wn out i
wst i
outwin u i
wuts u i
wut s u i
in ws u i
in s w u i
in s out w u i
wut i
wut i
us w out i
sn out w i
wst i
wut i
wut i
wut i
wut i
wut i
wut i
wut u i
out w u in i
out s u w in i
out w s in u i
outwn s u i
wut s u i
wout s u i