September 2022 Archives

Casting Perls before Splines

As I sit pondering my peas at the dinner table, my thoughts are unnaturally drawn to the similarity between these pulses and Perl. A famous poet once said that "For a hungry man, green peas are more shiny than gleaming pearls". From these green orbs on my plate, the mind drifts to a recent virtual conversation regarding logos, branding, rebirth and innovation in Perl. One wonders whether such heated debates are important, relevant and what it might mean for Perl in the future. The Camel (from the O'Reilly Book on Perl) has long been the image associated with the language, along with the Onion (Origin perhaps from Larry Walls' "state of the onion" presentation). Personally it is not something that I feel passionately about. "Perl, with any other logo would be just as quirky" as Will Shakespeare is reported to have said. But The Camel is the popular, recognisable standard "logo" with some, as yet to be tested, copyright and trademark "issues"

Any way I took it myself to analyse the situation and have finally come to the conclusion that we may be looking at the "problem" the wrong way. Perhaps we are looking at the bigger picture when we should seeing the picture bigger. Maybe, just maybe, that picture of a camel doesn't symbolise Perl, but in fact IS Perl...Perl code, that is. I know it is possible to make pictures that aren't valid perl code. But perhaps over the decades of use we have come to accept an illusion as a reality. When one gives such an illusion a "True" value, one also blurs the distinction between the Virtual Image and a Real Image.. You see a Virtual Image is an image that APPEARS to represent something, but only a Real Image can be projected.


So lets examine this image in cruder detail. What immediately pops out to the casual observer, is the silhouette clearly is a two line regular expression:

/rl /g

Now why on earth does this snippet appear in the camel in the classic book of Perl? Surely this can not possibly be by chance. Some predestination HAS to be involved. It is at this point, four aforementioned peas slipped off my spoon on to the floor. I don't know if any of the readers who are male and married, have had this experience before, but it was with enormous relief that I saw, glancing up, that this misdemeanor was missed by Mrs Saif.

But surely a sign...the rows of peas...and a regular can ONLY mean one thing.

$Logo="PEA\n" x 4;   # 4 rows of PEAs
$Logo=~              # Apply the code in the camel
/rL /g;
print $Logo;         # print result

#result:- "PErL PErL PErL PErL ";

The rows of "PEA"s get turned into a string of "PErL "s. It seems obvious to me that while we look in vain for the answer to our problems, it is the answer that finds us, the illusive emerging from illusions. A famous admiral said, putting his telescope to his blind eye "I see no ships of the desert". Of course he didn't. He saw Perl code.

Death: A Terminal Experience

A program being executed, self terminating on encountering an non-viable condition is a typical scenario in Perl programs. The death sentence can deliver information about the departed application to the user as justification and demand appropriate resolution for the subsequent reincarnation.

Now I know my code fails more often than it succeeds, and it is for this reason I am planning an alternative wake for the programmed parting of my future terminal applications. As a once-in-a-run-time event, death might be more elaborately delivered, something to be celebrated. The last words of a dying application softens the developers ensuing grief, while encouraging resuscitation with an appropriately delivered injection of code.

Imagine my code being transformed from:-

do_something_risky() or die "you evil monster $!";


get_away_with_it() or deathSentence($!)

producing something like this on the terminal:-


I know such distraction wastes time, there are probably many more error trapping and diagnostic tools available. These may be absorbed over time...I am not really an expert. But I am collecting a series of reasonably uncontroversial, hopefully humorous "epitaphs"...

About Saif

user-pic An Orthopaedic Surgeon, A Tissue Engineering Scientist, Lecturer, (and Hobbyist Programmer, Electronics Engineer and Roboticist)