Sending a hash to perl’s scalar function

While writing a test suite for one of my applications today, I came across an interesting result. Perl’s scalar function, if given a hash as an argument, will return something like “2/8” or “5/16”. Results can be identical for different hashes. There is no obvioius trend in changing of these results. As it turned out, scalar(%hash) returns information about hash buckets. The first number indicates the number of occupied buckets in the hash storage and the second number indicates the total number of buckets allocated.

I wasn’t sure in my guess, until I got a confirmation from Perl monks, which also pointed me to the “man perldata” bit describing the result.

GNU arch

GNU arch is getting so important to me that I have to create a special post for it with all the links. I’ll update it in the future too.

There are also few pages that describe how to use GNU arch with some specific project repository, like Vim and Garnome, but there is nothing particularly interesting there.

Fai – is the only arch frontend I’ve seen so far.

If you know of any other GNU arch resources, please, let me know via comments or email.

timestamp_image

This is yet another script to deal with images from digital cameras. It will scale (resize preserving the width to height ratio) down the image to the size you’ve specified and annotate (write on top of the image) it with date time taken from EXIF header of the image. Font face, size and color are configurable. Modified images will be saved with different name (as specified by the prefix variable inside the script).

This script is written in perl. It works with Image::Magick module and jhead program (since Image:EXIF failed to compile on my machine).

timestamp_image.pl

dump_photos

I am using dump_photos.pl script to copy (or move) images from my Canon EOS 300D to my computer. Canon’s in-camera filesystem is not very convenient to copy files manually, because images are distributed across a number of folders (100 images per folder thing). Canon original software is for Windows only and is way too complicated and slow for such an easy task.

My script uses standard Perl modules (Getopt::Long, File::Copy, and POSIX) to copy or move files to specified or default (date-based) directory. It also mounts the Compact Flash before processing images, and umounts it after everything is done. It also uses jhead to optionally rotate images based on the information in EXIF header.

Run “dump_photos.pl –help” for a list of options. Although it was tested only with my Digital Rebel, I think it should work fine with most of Canon cameras.

dump_photos.pl

PHP IN CONTRAST TO PERL

There are plenty of holy wars on the web that argue about superiority of PHP over Perl and vice versa. There are many people who prefer PHP, and there are many others who prefer Perl. I am, of course, in the Perl camp. I have programmed both Perl and PHP over some time, and there is no doubt in my head that Perl is way better than PHP as a language. The only point that I like about PHP is the how mod_php works. mod_php is a PHP module for Apache web server, for those who don’t know.

Anyway, back to the subject. I came across an excellent document titled “PHP IN CONTRAST TO PERL“. It summarizes the benefits of Perl compared to PHP nicely and clearly. It also links to a number of other resources on the subject, as well as provides the summary of those resources. Really neat paper and a must read for anyone who has or will have to deal with Perl and/or PHP.