Skip to main content


Showing posts from 2013

Perl5i Presentation to Toronto Perl Mongers

I presented a workshop based on the blog articles I wrote in March & April about perl5i.It went out on the Google Hangout, and the recording is available on YouTube, though unfortunately it stops short of the end. There may be a way that can be fixed, though i doubt it.Slides are available at Scribd, as are the speaker notes.Thanks to Michael for the module, Ingy dot Net for his YAPC mention of my Rosetta Code efforts, and Stephan Little for p5mop, his attempts to bring OO into core Perl5.

Dear John Nack #2

I suppose I should name this Dear Adobe, since John isn't actually involved with Lightroom or Photoshop. And I will, next time.

I LOVE the Adaptive Wide Angle filter in Photoshop CC .... except when I don't.

AWA is a filter like Lens Corrections, that places a preview of your image in  window of its own, where you modify various controls and view the effects in more-or-less real time. When you click OK, the modifications are applied to the entire image. While there are a number of options, which vary the amount and type of controls available, I use it on panoramas. You draw a line on the image, by clicking the endpoints, and a guide line is presented, bisecting a circle. By clicking where the line and circle intersect, you can cause the line to rotate to a different angle. But unlike a simple image rotation, you can have many lines, rotated to various angles, manipulating a mesh superimposed on the image.

I use it to straighten out panoramas, so my horizontals are horizontal a…

Dear John Nack #1

Dear John.

Please arrange for Adobe to implement the following feature for me.

I love the "Visualize Spots" checkbox in the LightRoom / Camera Raw "Healing Brush" as a way to locate dust spots that need to be cleaned away.

The problem is, you need to be zoomed in at 100% to effectively deal with sensor dust, and sometimes it's not clear whether a particular mark on the screen is a fault or a feature. Then you need to click to normal view, and back to the edge-detection view. It's a problem having to move the cursor down to the checkbox, back to the spot to clean away, and back to the checkbox. A key-chord combination to enable and disable the edge-detected view would be a great benefit ... and there are so many to choose from! It could be Ctrl-H, since it's a Hide operation; or like overflow/underflow indication, it could simply use the control key. Only while healing, you understand.

That's all right, no royalties are necessary.


16 July .... Br…

If I Could Change Perl

Is there something that irritates you about Perl? One little thing you wish you could change, to make life so much easier?

For me, it's the way declarations work. Whether it's with local, our or my, you can declare a variable name, or a list of several variable names:

my ($x, $y, $z); Of course, you can initaliaze variables as you declare them.
my $bank_balance = -999_999; my ( $x, $y, $z ) = ( 0, 0, 0 );
But if you have a number of variables to declare, and they aren't directly related to each other, as (x, y, z) clearly are, it would be so much better to declare the variable and immediately assign a value to it on the same line, the way C, Javascript and numerous sensible langages do.

Currently, 'my', 'our' and 'local' expect a variable name, or a list of mariable names. So one possibility would be to provide an alternative form which takes a hash. Ideally, values defined in one line could be used lower down.
my { $sides => 3, $lengths =…

Learning Perl5i #3 revisted

I was somewhat uncomfortable that my solution to the combinatorics task, which involved a single, not very long routine, became so long with the addition of command line processing and POD  documentation. For one thing, while it had some information about how to invoke the routine, it did not have tests.

I still feel that a book on programming, say, should have a fully-implemented solution once a chapter, perhaps, to show the way things should be done. But that is too long for every single bit of code. Full documentation and sample implementations stretch on too long, compared to the few lines a snippet actually deserves.

Providing tests may still be appropriate. They take up less space than full documentation, yet explain how the various components work, by the very act of stress-testing those lines of code. Tests provide examples of how the code should be invoked.

Revising the combinatorics task into a module, this generates:

use perl5i::2;

# ----------------------------------------
# …

Learning Perl5i #3

I've long admired the way functional languages specify multiple implementations of a routine for different sets of argument values, to detect terminal conditions. Converting a Perl6 solution  of a combinatorics task to Perl5i, I realized the plain Perl solution isn't necessarily all that bad, either.

The problem is to list the different ways you can select M elements from a set of N. Select 2 elements from a set of 4 would lead to the values ( 1, 2 ); ( 1, 3 ); ( 1, 4 ); ( 2, 3 ); ( 2, 4 ); ( 3, 4 ). Oh yeah, they want the characters in each combination in sorted order, and  the list of combinations sorted, too.

So it all consists of a single routine which gets invoked as combine(3, ['a'..'e']).

Ignore the first couple of lines, for a moment. If the first character of the set exists in a combination, it must be in the first position, since the characters are in sorted order. That means the remainder of the combination must be one character shorter, made of the …

Learning Perl5i #2

Continuing the exploration of Perl5i beyond part one, I decided to treat perl5i as a language and use it to implement tasks at Rosetta Code.

Since Moose is a complete OO solution, I use a lightweight approach to OO, where used.

The first RC task I implemented is 100 doors: see the full implementation.

In terms of documentation, I gave each routine a small header in which I show how the routine is invoked, specify the inputs and outputs, and summarize the primary actions of the routine.

Since the task is defined in terms of a number of doors, and operations on those doors, it seemed appropriate to use an object. "some object" + "operations on that object" ==> "segregate into an OO implementation".

I used a simple constructor with initialization performed in _init() to simplify subclassing. The constructor doesn't need to be modified, just a new _init() written to handle additional attributes or arguments, if any. The new implementation can handle th…

Learning Perl5i

I've been looking at the module perl5i, which puts a sideways twist on Perl, eliminating tons of boring boilerplate, and introduce many conveniences. In this case, the i eliminates complexity.

Installing perl5i installs a number of other modules as well, on the other hand life becomes better once they are installed.

If you don't have cpanm or one of the other improved CPAN installers, the simplest way is to install perl5i and its friends using the command

sudo cpan perl5i

You may need to type in yes to have cpan  install dependencies. Some modules are needed only temporarily during installation, and you are asked whether you want them permanently installed. Perl modules don't take up very much space, so I always go for it. Installation is a bit different on Windows or Linux machines, but you can figure it out, you're a mighty Perl programmer!

One consideration is that major versions of perl5i may change in drastic ways. But you don't include perl5i; what you specify…