| You are the 32559th visitor to this page since March 20, 2001. |
|---|
This page contains some information about Perl programming. It is really not organized in any special manner. My intention was to collect some stuff that I occasionally find useful, and give access to it. Browse through the material if you like, and if you find anything useful anything interesting, or you think that something is missing send me a note and I might get around to doing something about this page.
I have recently added a Perl Cookbook with recipes for solving some problems you might run into. The recipes solves problems for which I haven't found a solution in the Perl Cookbook by Tom and Nathan. The contents of this page is:
perl5 is used.
perl -ne '$n += $_; print $n if eof'perl5 -ne '$n += $_; END { print "$n\n" }'
cut(1),
if you cut out a numerical field from an output. There is also a C
program called sigma
that does this faster.
perl5 -pe 's/(\w)(.*)$/\U$1\L$2/'perl5 -pe 's/\w.+/\u\L$&/'
perl -e 'dbmopen(%H,".vacation",0666);printf("%-50s: %s\n",$K,scalar(localtime(unpack("L",$V)))while($K,$V)=each(%H)'
perl5 -p000e 'tr/ \t\n\r/ /;s/(.{50,72})\s/$1\n/g;$_.="\n"x2'
perl5 -pe 's#\w+#ucfirst lc reverse $eg'
perl -pe '$_ = " $_ "; tr/ \t/ /s; $_ = substr($_,1,-1)'
Set::Scalar from the
Perl Modules List. Comes with a test program.
This package is also registered at CPAN, so go check there if you like.
c++stat A program that collects info about C++ programs. Like LOC, % comments, etc. This is just intended to be a test. diffsolve This is a small script that solves difference constraints using a variant of the Bellman-Ford algorithm for Single-Source Shortest Path. Available is also a simple example of a set of constraints. A program that checks if an e-mail address is syntactically correct. The definition is taken more or less straight from RFC-822, so it should work. By application of some Intelligence® is is propably possible to make it slightly more effective. lcomplexity A small program that computes the linear complexity profile of a sequence of bits using the Berlekamp-Massey algorithm. The bits are fed to the program as an argument consisting of a sequence of zeroes and ones. mail-form This is a hack inspired by the form-mail.plprogram written by Reuven M. Lerner. This is a slightly more generic interface to allow people to send mail.
Instead of having a hard-coded reply and mail, this script fetches a mail template and a reply template using HTTP, perform some simple substitutions on the templates, and then send a mail and a reply.match I wrote this script since somebody in comp.lang.perl.misc requested a Perl script to search for words matching certain patterns. I.e. if you supply a pattern "ABBA" you should find all four-letter words beginning and ending in some letter (the same) having two other letters in between (also the same) which is different from the letters in the beginning (and the end). Examples of such words are "deed" and "noon". It should on the other hand not match "aaaa" since the first and second letter has to be different.
pgrep A Perl version of the grep(1) command. The main difference is that it accepts Perl regular expressions instead of the normal regular expressions. Manual included in runoff format. rename Small script written by Larry Wall. It is used to rename several files at the same time. Manual included in runoff format. sum-garbage A program that takes as arguments a number of users and write a table of the amount of "garbage" that he/she has. The script uses the module File::Findsupplied in the standard distribution of Perl 5.sum-process A program that does a ps auxand collects some statistics about each user.uniqpath A small program that removes duplicated pathname in your PATH environment variable. Will print out the new path on standard output. wordcount A program that counts the number of occurances of words in a text. Wrote it mainly to test the speed of associative arrays. Try something like { man nroff; man perlfunc; man twm; } | time wordcount
mh2ns A program written to convert an entire MH hiearachy of mails into the format used by Netscape.
scheduling.tgz A small package of two simple Perl program to compute the validity of tasks under Rate-Monotonic Scheduling. There is also a program that computes the maximum response time for each task in a set of tasks using Response Time Analysis. Rate-Monotonic Scheduling and Response Time Analysis is used to compute and validate static scheduling schemes for real-time systems. pack Simple script to pack strings into binary formats. Uses the internal pack command inside Perl.
There is a Makefile (for GNU make) and a typemap, which are used when constructing a loadable module.
simple XSUB package
[ XSUB
- Perl Module
- Test Program ]
simple module is a short example of how an
Xsub may look. It contains a minimal amount of code and is
intended as a demonstration only. The package consists of the
Xsub file simple.xs,
the Perl module simple.pm
used to bootstrap the Xsub and finally a test program
simpletst.pl to
test the package.