April 2012 Archives

Is Try::Tiny still recommended for exception handling in Perl 5.14 or later?

Because I am interested in the result, I wanted to make the community aware of this question on StackOverflow. If you have an opinion answer there. Perhaps I will summarize the results here when the discussion warrants.

Alien::Base Perl Foundation Grant Report Month 2

After last month’s breakneck development pace, I knew this month wouldn’t be as gratifying, and indeed it turned into quite a slog.

This month involved lots of little bug fixes, posting dev releases to CPAN, then waiting for test results from CPANtesters. As a side note, there are a larger number of reports coming from Solaris and BSD than I would have expected. Sadly one of the bugs that still hasn’t been sorted out is this recurring Solaris bug when changing working directory. It would appear that I am going to have to find a Solaris box or VirtualBox appliance, since waiting for test results for every fix attempt would take far too long.

I do have some nice things to report. I have received help from fellow WindyCity.pm member David Mertens and new contributor JT Palmer this month, so thanks guys! Next I have just pushed a new dev release which (again) changes the mechanism of dynamic loading; this one more reliant on DynaLoader’s facilities rather than munging ENV variables. This seems to be more platform independent, or I should say, as platform independent as p5p has written into it. I have much faith in them! Preliminary results seem promising. David had been having problems with a candidate Alien:: module that he is writing and this release seems to have fixed it. I hope to see Darwin and Win32 start passing too (gasp).

With that said, I am still targeting more documentation and a basic testing framework before a 0.001 alpha release. Seems like I’m always saying this, but I hope this will be coming shortly.

Fork Alien::Base on Github and note that the 0.000_009 dev release is still contained in the dlopen branch. I will merge it once the tests seem to bear it out.

One Unit of Stepping Up

In the mold of Buddy Burden’s great post Stepping Up, I wanted to share a recent pleasant result of contacting a wayward author.

One or two of you may have seen my MooseX::Types::NumUnit which brings “dimensional” (read: units) types to Moose objects. I had been using two different unit engines Math::Units::PhysicalValue and Physics::Unit. This was essentially because I hadn’t been able to figure out how to get the functionality of both out of just one, though I was rather sure it should be possible. Recently though, I spent some of my diversion time on the problem and settled on using only Physics::Unit. This is new version was pushed to CPAN a few days ago.

Now that I have settled on one underlying module, it came time to address some of my druthers with that module. Notably it lacks the shortcut for millimeters: mm. I was able to hard code that shortcut into my module so my users wouldn’t see that wart, but one that I couldn’t fix was nm meaning nautical miles rather than the much more common (at least in my field, physics; sorry navigators) nanometers. There was no way to override the preset.

I have taken on a lot lately and didn’t really want to take another CPAN module, but it seemed like that was going to be the case seeing that Physics::Unit hadn’t seen a release since 2003. Worse than that, seeing as units haven’t changed much since then, the author Chris Maloney (KLORTHO), hadn’t published any other modules, so 2003 was his last activity. I opened GMail with a heavy heart, “its time to try to find a wayward author, just to take over another module, just to make a few minor changes”. The first email bounced. I tried again, googling for his name. But here is where the story changed.

To my delight, his reply started “Wow, this is a blast from the past! I’m very happy to get this email, and especially that you find the module useful. I have always had it on my to-do list to go back and update my CPAN entry with a few things, including my email address.”

He and I have been working on the changes I envisioned, he is using it as a reason to learn git and GitHub. It has me very excited, not just for a new release of an old module, not just for the improvement of my higher-level module, but for the human experience of CPAN. I know there have been some public kerfuffles lately; I hope that doesn’t put off too many people. CPAN and the Perl community have so many nice people, even those that have strayed for nearly a decade.

Reach out to the author of that module on your mind and ask a question, offer to help, its time to Step Up. It might be more pleasant than you expect.

Announcing Physics::RayTransfer

While I am still working out the bugs from Alien::Base I have released a little scientific side project named Physics::RayTransfer.

Calling all laser physicists! Does modeling your cavity using Ray Transfer (ABCD) matrices bore you? Do you regularly forget to include one of the matrices on the reversed arm on the round trip? Do you hate using that symbolic mathematical language? Try Physics::RayTranser!

It slices, dices, makes julienne fries and of course is a totally object oriented way to model your laser cavities (or other optical systems). No round trip matrices needed!

use Physics::RayTransfer;

# build the system using helper constructors
my $sys = Physics::RayTransfer->new();

# parameter for for cavity length
# from 0 to 10 in 0.1 (cm) increments
my $d = [ map { $_ / 10 } (0..100) ];

# spot size at right mirror (OC) at 1063 nm 
# for each cavity length!
my @data = 
  map { $_->[1]->w(1063e-7) }

Finally, some of you might complain that the whole thing is written in MooseX::Declare and so you have to install that whole monstrosity just to use it. Oh well, its really fast to write, and I find writing OO scientific code very intuitive using it, so get over it. :-)

Have you seen perl-reversion?

I just wanted to share a “new to me” script in case its new to any of you too. After a quick twitter exchange between me and @rjbs he told me about the script perl-reversion which is a part of the module Perl::Version.

Just run

perl-reversion -bump

in your distribution folder and it will find and bump the version numbers in all the files! What a time saver when developing! Thanks RJBS for sharing this with me and thanks Andy Armstrong for releasing it!

Edit: A previous version of this post decried the fact that the script was not installed but rather was in the examples folder. After reading further I see that it IS in fact installed by using some Makefile.PL trickery. Why not just put the script in a directory named bin rather than examples and it will be installed without trickery?

About Joel Berger

user-pic As I delve into the deeper Perl magic I like to share what I can.