Tuesday, 13 August 2013

A Look at Touching Files

Last time, I created a function to determine if a target file was out of date with respect to its sources. Now I want a function similar to UNIX' touch(1) that will update the atime and mtime of a file. And, like touch(1), it should be able to create empty files. The way to do this is to use Perl's utime function, which is based on UNIX' utime(2) function.

Monday, 29 July 2013

A Look at Finding Out-of-Date Files

On occasion, I need a script that will updates reports but only when the sources have changed. This is typically creating an XML file from log files or creating a static page for a web site. Here is a function to determine if the sources have changed after the last time the report was created.

Thursday, 25 July 2013

A Look at Dumping

I used Data::Dumper a lot but it leaves something to be desired. By adding a function to MyUtils.pm, a simpler interface can be achieved.

A Place for the Tests

In a previous article, I created an empty module for some utilities. Now is the time to populate it...and to develop tests for the subroutines.

Friday, 12 July 2013

A Look at Conditional Compiling of Diagnostics

From time to time, I add diagnostic messages to be printed by my code so I can track what the program is doing. I often wondered if there was a way to get Perl to conditionally compile these statements and to get it to do so automatically. Here's how:

Sunday, 7 July 2013

A Look At My Utility Library

Although there are many useful utility subroutines in Perl's standard modules, there are some that are missing. I'm going to spend the next few posts describing a few.

Sunday, 9 December 2012

A Look at Cartesian Products

Copyright 2012 by Shawn H Corey. Some rights reserved.
Licence under CC BY-SA 3.0

Problem: You have a number of sets and you want all the combinations when choosing one element from each set.

In mathematics, these combinations are called the Cartesian product. They are also known as cross-products. In the database world, they are sometimes called cross-joins.

This article is to show how to create them using Perl's glob function and how to create them in a subroutine.