Friday, May 20, 2011

PDL::IO::Export2D now uses Dist::Zilla

My module (PDL::IO::Export2D) has made the switch to Dist::Zilla and I am impressed with how easy it makes authoring modules for CPAN!

My source tree now only consists of the actual module, the test scripts, the Changes file, (yes, there is the README.pod, but that is generated by D::Z for github's benefit) and the dist.ini file for Dist::Zilla. This file contains the distribution metadata and the plugins / plugin configuation to be used in the build process.

name = PDL-IO-Export2D
version = 0.030
author = Joel Berger <>
license = Perl_5
copyright_holder = Joel Berger
abstract = Provides a convenient method for exporting a 2D piddle.


[ReadmeAnyFromPod / pod.root ]
filename = README.pod
type = pod
location = root

... yep thats all. It makes my other files (meta, readme, etc), it even puts the version number in the module file for me!

Now if I want to make a small change and publish it, all I need to do is make the change, increment the version number in dist.ini then do

dzil build
dzil test

and finally upload to PAUSE. Simple, convenient.

Thursday, May 19, 2011

Installing PDL

The PDL wiki has an instruction set to install PDL from CPAN, however I find it is missing a few things so here are my instructions (also my instructions use CPAN when possible):

Step 0) If installing over SSH (if not go to Step 1)

If you are installing over an SSH shell be sure you used the -X (and/or the -Y) flag when connecting (ssh -X Then execute


to allow OpenGL to work correctly.

Step 1) Install system packages

sudo apt-get install libxi-dev \
libxmu-dev freeglut3-dev libgsl0-dev \
libnetpbm10-dev libplplot-dev \
pgplot5 build-essential gfortran

Step 2) Install Perl modules

I use cpanm, one may also use cpan, but it makes you hit 'y' many more times

cpanm Term::ReadLine::Perl Inline Astro::FITS::Header ExtUtils::F77
cpanm -v PGPLOT OpenGL
cpanm -v PDL

I like to use the -v on the graphical modules and PDL because they have tests where it helps to read the output that cpanm suppresses. If you don't need that, you may omit the -v.

Also if it seems that any of those hang, try hitting the enter key to continue. Some of the plotting tests require you click around, do so, sometimes hitting the right mouse button as well. You may need to close the PGPLOT server window at some point as well (black window that doesn't seem like its doing anything).

Step 3) Test the tricky modules

perl -e '
use PDL;
use PDL::Graphics::PGPLOT;
use PDL::Graphics::TriD;
print "success\n"'

Wednesday, May 18, 2011

Perl in Go!

I have been meaning to learn a compiled language and Google's Go language has intrigued me. It's a new compiled language with high-level features. Finally though I think I have found a reason to try: Campher, it's Perl in Go! Now I have all the security blanket of a language I know and love in a new one!

Saturday, May 7, 2011

Dynamic vs Static scoping

Finally an explaination I can understand

In other words, the dynamically-scoped (local) variable $x is resolved in the environment of execution, rather than the environment of definition (my).

... from wikipedia

Friday, May 6, 2011

On using PERL -- The "Print Evaulate Read Loop"

Anyone who has gotten deep enough into Perl programming has been asked questions about PERL. Supposedly this is another programming language related to Perl, but only used by newcomers.

I submit however that this is the natural course of events with the Perl noob. It is the PERL flow -- Print Evaluate Read Loop.

Many people are familiar with the REPL (Read Evaluate Print Loop) mechanism of program interaction. This simply is a program that Reads a line of code, Evaluates what that line does, and Prints the response, Looping in order to do it all over again.

PERL is very similar. The noob Prints out some Perl code, perhaps amending some totally unrelated and possibly aweful old code found online somewhere, Evaluates it on some poor shmucks on say Stack Overflow, asking why it isn't doing some task (which it had no earthly possibility of doing), Reads what he should have read in the documentation, and finally Loops, doing the cycle over again.

In truth I am happy to help the Perl noobie from PERL to Perl, but every now and again you would think they would learn to capitalize it properly. I cannot figure out how they can all say Python (never PYTHON) but not Perl.