example

A Perl module template (template code for a Perl module)

If you've ever needed some template/boilerplate code for creating your own Perl module, here's some sample code intended to give you just what you wanted. Feel free to copy and paste the Perl code shown below and use it as a template for creating your own modules.

How to use this sample Perl module

If you've never created your own Perl module I recommend first seeing how this sample code works. Here's all you have to do to get it running:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

A MySQL database table index example

MySQL FAQ: How do I create a MySQL database table index?

Here's an example of how to create an index on a MySQL database table. In this particular example my table uses the MySQL InnoDB database engine, but that doesn't matter too much -- it just happens to be a MySQL database engine that supports foreign key relationships.

To get started, here's the SQL definition of a MySQL table I've named ftp_files:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

How to get SOAP::Lite working with the Apache CXF web service

I'm not going to spend too much time showing this Perl SOAP client solution, but if you're having problems using the Perl SOAP::Lite module as a client running against a modern web service, this sample Perl code may help solve the problem.

First, I'd like to show what my original Perl SOAP client code looked like when I was using it as a SOAP client running against several Axis and XFire web services:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

A simple Expect script to test an FTP server

I'm not going to explain this very much, but here's an Expect script that I wrote to test an FTP server:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

My Windows Ant/Tomcat web application build process

I don't like the off-the-shelf process of developing web applications with Ant and Tomcat on Windows computers. Rather than get into my angst, here's the way I think the Ant build process should work with Tomcat:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

Debug Ant build problems with echo statements

Ant FAQ: How to use echo commands to debug Ant build scripts.

I've been moving back and forth between a ton of different computers lately -- Mac, Linux, and Windows computers -- and I had some problems with an Ant build script. This particular Ant script is complex, and I kept making mistakes, and needed a good way to debug the build process as I set up my application on these different systems.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

Ant tip: How to dynamically add all your jar files to your classpath

Here's some sample code you can use in your Ant build scripts to add all the jar files in a directory tree (typically your lib directory) to define a classpath for your Ant build/compile task:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

A shell script to search multiple jar files for a Java class or pattern

I've found that there are several times when I need to be able to find a Java class inside of a jar file. Usually this happens when something isn't working, and I get something like a Java ClassNotFoundException. In the process of debugging this problem -- especially if I'm using a jar library that I haven't used before -- I list the contents of one or more jar files to debug the problem.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

The beginning of a MySQL database script

Here is some code that I use at the beginning of a MySQL database script to (a) create a database, (b) create a local user to access that database ('foo_user'@'localhost'), (c) create a remote user that can access the database ('foo_user'@'%'), and (d) then use that database (which I need to do before starting a bunch of CREATE TABLE statements):

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

How to use the Commons IO project to create, delete, and move files and directories

I wrote the following Java class today that is a "helper" class for a project I'm working on to create a web interface for Nagios. The Nagios part isn't too relevant, because mostly what I'm trying to show here is how to use the Apache Commons IO project to make it easier to interact with files and directories from Java code.

In short, the following Java class shows how to use the Commons IO project to accomplish the following tasks. Without any further delay, here is the complete source code for my class:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.