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 host.name.etc). Then execute

export LIBGL_ALWAYS_INDIRECT=y

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.

Sunday, April 24, 2011

OpenGL over SSH

Just a quick note, if one needs to use OpenGL over an SSH X Forward, you may need to do "export LIBGL_ALWAYS_INDIRECT=y" on the remote computer. FYI

Monday, April 18, 2011

Published my first CPAN module!

Well I have jumped in finally, I have published my first CPAN module, a PDL export tool. Beyond being useful it was a good first opportunity to publishing something simple before doing something more involved, like the Physics modules that I might end up publishing, or the FLI camera Perl module/driver that I have been working on.

I have set up a github repository to host my work. If you want, you can follow the development of this and other future work there.

Friday, April 15, 2011

Scientific Data Crunching on Perl (PDL)

A good primer on PDL for those of us who know Perl but find it a little hard to use the PDL documentation.

http://www.perlmonks.org/?node_id=598007