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
Windows Active Directory to PDF Phone List
on Sep 19, 2006 at 07:42
0 replies by davis

Here's a script to extract telephone entries from a Windows AD via Net::LDAP (thanks g0n!) and output them to a LaTeX file to be process with pdflatex. The results aren't too terrible.

You'll probably need to customize it; we, for example, store "Mobile speed dial" numbers in the "Pager" field. We also deliberately separate based on the physical building — YMMV.

I'd recommend separating the template into a separate file, I included here inline because it's easier to download.

unichist -- count/summarize characters in data
on Sep 19, 2006 at 03:02
0 replies by graff
A nice tool for getting to know your unicode or other non-ASCII text data. For all files named in @ARGV, or all data piped to STDIN, we count and report how many times each character occurs, and optionally summarize the quantities according to the current standard set of Unicode "charts" (groupings of characters according to language or function). Also lets you convert legacy encoded data to utf8 on input. Check the POD for details.

(updated to fix a minor glitch involving code points gt "\x{2FA1F}")
(second update: added logic to check for malformed utf8 and adjust output if needed) (third update: major revision (thanks to Jim) to use unicore/Blocks.txt instead of __DATA__; also added "--names" option, changed "--chart" option to "--blocks", and altered spacing of output table columns)

Move/merge directories
on Sep 14, 2006 at 19:15
1 reply by diotalevi
This allows you to merge two identical-ish directory trees. It won't overwrite any files if there's a conflict.
Fixup tabular text file
on Sep 14, 2006 at 18:37
1 reply by diotalevi

This does several things to fixup tabular text files to be more regular including:

  • Removes empty trailing rows
  • Adds missing trailing columns
  • Warns if the header is missing columns
  • Warns if the file isn't a text file
  • Warns if there is only one column.
  • Dos2unix line ending conversion
    • Fixes Excel formatted numbers:
    • (...) parens around negative numbers
    • Optional $ sign
    • Optional commas
diotalevi's grep
on Sep 14, 2006 at 18:29
1 reply by diotalevi

This grep is much like everyone else's perl reimplementation of grep. It's only distinguishing features are automatically looking inside bzip2, gzip, zip, and tar files. It borrows the pretty formatting used by petdance in ack.

This started life as an improved version of the grep that comes with the Solaris which isn't recursive.

cutf - cut by field name
on Sep 14, 2006 at 18:23
0 replies by diotalevi
Print selected parts of lines from each FILE to standard output. Selects parts by field name unlike /usr/bin/cut which uses column numbers.
cksum contents of a tarball
on Sep 14, 2006 at 18:17
1 reply by diotalevi
Produces cksum info on the contents of a tarball while leaving the minimum files extracted at any given moment.
socksumm -- Display a summary of open sockets
on Sep 13, 2006 at 06:59
0 replies by grinder

I've had this lying around for some time. It just takes the output of netstat and summarises the information à la vmstat, iostat. I have used it for keeping an eye on large daemons that have shown a tendency to go mad.

I don't see that there's anything else to add to it, but I'd be interested in seeing if anyone has suggestions and ways it could be improved.

update: now with Win32 support! thanks Discipulus for the suggestion

Email using sendmail
on Sep 12, 2006 at 04:05
1 reply by alandev
hi monks
i wrote small script to send mail from my unix box.
uhead: "head -c" for utf8 data
on Aug 31, 2006 at 23:25
0 replies by graff
This simple command-line utility does for utf8 text data what GNU "head -c N" does for ASCII data: print just the first N characters of files (or STDIN). Since Perl's built-in "read" function is able to read characters (rather than just bytes), this a pretty trivial exercise. But I wanted to post it anyway, because it's a nice demonstration of a fairly complex process (handling variable-width characters) being made really simple.