Sam Vilain's Perl modules

Here are some of the modules I've written, in order of last release.


Quite often, you want to create an object class, that only holds data but doesn't have any methods. If you don't want to break encapsulation, this means writing a large module that is purely monkey code.

By using Class::Tangram as a base class and defining a package global $schema, you will get, for free:

  1. The ability to create new objects of that class with ClassName->new(), and pass initial values in attribute => value pairs.
  2. The ability to read attributes of those created objects with $instance->attribute() (or $instance->get_attribute()).
  3. The ability to set attributes of those created objects with $instance->set_attribute($value).
  4. Extra checking, that will throw exceptions (at run time, or hopefully test time ;)) if you try to set an attribute that isn't defined (typos!) or set an attribute to an illegal value. Exactly how far you want to go with defining what is "illegal" is up to you. Remember: Garbage In, Garbage Out. Don't let the garbage in to your objects!
  5. A circular references breaking function.
  6. A rich set of attribute types that behave in a very DWIMy way, such as "sets" and "arrays".
  7. *New with Class::Tangram 1.07* ClassName->set_init_default (attribute => value); sets default values for newly created objects - great for "configuration" functions, etc.
  8. *New with Class::Tangram 1.08* Support for transient attributes (attributes that are not stored in a Tangram storage)
  9. *New with Class::Tangram 1.10* Make an attribute "required" to be either defined or logically true with a single keyword.
  10. *New with Class::Tangram 1.12* use of Perl's AUTOLOAD feature has been completely removed, resulting in roughly 900% faster execution of simple get/set methods.

But wait, there's more! If you then at any stage wish to make your objects persistent, you can plug them in to the excellent Tangram OO Persistence engine. Pure OO enlightenment.

Class::Tangram documentation
Source download: Class-Tangram-1.12.tar.gz
Debian package download: libclass-tangram-perl_1.12-1_all.deb


Lingua::Translate provides a framework for translation servers, such as the fish or SysTran. Translation via Babelfish is performed via the Linga::Translate::Babelfish back-end, which in turn communicates via LWP::UserAgent to the altavista site. This code was mostly taken from the WWW::Babelfish module.

Version 0.03 includes character set conversion via Unicode::MapUTF8.

Version 0.02 includes working translation via Babelfish or SysTran backends.

Lingua::Translate Documentation
Lingua::Translate::Babelfish Documentation
Lingua::Translate::SysTran Documentation
Source download: Lingua-Translate-0.03.tar.gz
Debian package download: liblingua-translate-perl_0.03-1_all.deb


Pod::Constants is a way to let you use the embedded source documentation format, POD, as a master source for your globals, etc. Previously there was the capability using Pod::Parser, but actually using it in a program to put your constants in the POD was not tidy. With this module, you can do things like this:

=head2 PI

The value of PI used by this program is 3.14159


my $pi;
use Pod::Constants PI => sub { ($pi) = m/(\d\.\d+)/ };

This makes it great for writing programs for which when you make a change, you make it in one place only. It keeps the documentation in sync. Use it! :-)

Pod::Constants Documentation
Source download: Pod-Constants-0.15.tar.gz
Debian package download: libpod-constants-perl_0.15-1_all.deb

Not Very polished modules

Yeah yeah yeah, I'll CPAN these some time...


Get the inode number on a readdir: ReadDir-0.01.tar.gz


mknod without system() - Sys-Mknod-0.01.tar.gz


Some sorely needed supplements to the map() function family -

Sam Vilain,

Back to home page