Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

cog (4665)

Journal of cog (4665)

Thursday July 24, 2008
01:01 PM

Happiness is...

...when you notice you just did with 23 lines of code what the previous programmer did with 425.

sub parse {
        my $self = shift;

        my $feed = XML::Feed->parse( \$self->get_content() );

        my @items;

        for my $entry ( $feed->entries ) {
                push @items,
                        title => $entry->title,
                        link => $entry->link,
                        description => $entry->content->body || $entry->summary->body,
                        date => $entry->issued || $entry->modified,
                        author => $entry->author,

        return {
                feed_title => $feed->title,
                items => \@items,

That over there is parsing Atom, RSS1, and RSS2 just the way the system needs it to be done.

And yes, the project where those 425 lines could be found was the one I mentioned a few days ago.

(apparently the code tags are messing up the allignment of the => and ||)

Monday July 21, 2008
03:14 PM

Three weeks at my new job

Three weeks have passed.

Here are the highlights:

Days 1 - 3

  • introduced to dozens of people, saw a bunch of presentations about projects and methodologies;
  • after meeting all of these guys, I had a feeling that I could give an introductory Perl course, so I suggested that to the powers that be;

Day 4

  • got introduced to my first project, a remake of an already deployed system;
  • the room for my one-day Perl class was confirmed (a very nice room with capacity for 40 attendees) and the course was announced;

Days 5 and 6

  • gave the first steps in my project, prepared the slides and exercises for the course (I already had some material ready);

Day 7 (a Wednesday)

  • 40 people (the limit for the room) had registered and showed up, counting people from Perl, PHP, Python, .Net and JavaScript, and also a handful of sysadmins;
  • IMHO, the course went very well;

Days 8 - 12

  • more coding, and a suggestion of a Regular Expressions training with me lecturing; I say yes;

Day 13 (another Wednesday)

  • almost 40 people show up, counting a lot of people from the first session and a bunch of newcomers;
  • the course goes well, and I'm happy that Adam's "Perl on a Stick" allows for a couple of Windows users to install and have perl running in just a couple of minutes;
  • there was another course (on Security, I believe) in the same day (which appeared to be non-optional for those who were attending); I've been asked to repeat this class for those guys;

Days 14 - now

  • more coding; the project currently has a total of 1690 lines (which includes documentation and around 25% of empty lines; I know, that's less than 200 LOC a day, but hey, I spent some time designing the thing in the beginning; maybe I could hack something into the repository to create a graph that would show the evolution of this number through time... hum... now I'm curious...);
  • there's documentation in all the modules, a test suite, and a more general/overview documentation in the project Wiki, which resides within the Trac system I'm using (44% of the first milestone tickets are completed).

And now for some non-chronological highlights:

  • I'm enjoying this a lot;
  • While there are very proficient Perl people around, there's also a few people who are not so skilled in the language (but all of whom seem to be very bright) that now feel comfortable asking me for help (not sure if they felt comfortable or not asking others for help, but I seem to be a regular Perl go-to guy right now, and if it helps people, I'm very happy with it). So far I've been called to explain an if-clause in a one-liner was badly written, that a 'use XML::Simple' inside an eval should have actually been a 'require XML::Simple', to help sharing runtime-generated code references between threads (which was solved with a dispatch table and a tie), and to track down the whys of a process resulting in a never ending stream of SIGSEGVs after an arbitrary running time (and I haven't solved this one yet);
  • There's free fruit in the office;
  • I'd like to say that the rule of thumb here is that of "two monitors per person", but I may be wrong... the rule may actually be "three monitors per person" (counting laptops, yes);
  • I've been asked by more than one person to give a course on Object Oriented Perl, and when I mentioned a list of things we could have courses on, it was clear that a Test Driven Development class would have enough attendance to justify it.

And that's it for now (of what I can tell publicly).

So far so good.

Sunday July 20, 2008
12:13 PM

Why I'm not buying an iPhone

Because I don't like being abused. says: "Starting at $199."

However, here in Portugal, it costs 600€, which at the current exchange rate is something like $951.

Supposedly, operators should be providing the iPhone at a lower rate, possibly demanding a 24 month contract, or something like that.

Unfortunately, operators in Portugal are going a step further, demanding extra things for a client to qualify for the lower prices.

Vodafone - lower price

With Vodafone, you have to already have been a client 6 months ago, and you also need to have a number of points in your Vodafone account so you can trade for the discount.

Even then, the lowest price is 219,90€ a month, with a monthly rate of 64,90€ which comprises 500 minutes, 500 sms, and 500MB traffic. You also have to sign for 24 months.

Vodafone - regular price

The regular price is of 599,90€. You don't have to sign for the 24 months and you can choose the plan you want, but hey, the regular plans are really crappy, when it comes to data.

Optimus - lower price

The cheapest you can get the iPhone from Optimus is for 245€, but you gotta have 4200 points in your Optimus account.

Optimus - regular price

The regular price at Optimus is also 599,90€.

What is this?


Wednesday July 16, 2008
05:25 PM

Legacy Code :: When it's just not worth it

So there's an already deployed system.

It doesn't take more than a glimpse to notice the following:

  • no versioning control, just the deployed version
  • no documentation
  • no comments
  • commented code
  • a bunch of scripts, one for each step of the algorithm
  • a Perl system, shell scripts that invoke the Perl scripts in specific orders, a PHP backend
  • a bunch of stuff in crond
  • a bunch of files ending in ~, .bak or .old
  • a directory called bk (yes, from backup)
  • a couple of files with different names but with the exact same content
  • an ever increasing number of processes, which sometimes have to be killed when the machine is running too slow
  • a database with tables that have several columns that have never been used
  • several modules, in the same namespace, with replicated code among them
  • several modules with replicated code inside them (copy-paste, yes)
  • way too many lines of code with more than 80 characters
  • to be honest, way too many lines of code with more than 120 characters (the record is 588)
  • lack of indentation
  • lots of spaghetti code
  • a bunch of things you'd never do in Perl
  • nested if clauses where you could use a simple dispatch table (these ones make my eyes hurt)
  • for and foreach mixed around (at least you should pick one and stick with it...), sometimes Perl-style, sometimes C-style (sometimes using $i, sometimes using $xy, sometimes using other variables)
  • hardcoded passwords
  • serious security problems (at least judging by the amount and complexity of SQL queries constructed without using placeholders)
  • a testing directory with nothing resembling tests; just a couple of scripts which you run and then you look at the output to see if it's what you were expecting, assuming you know what the output is supposed to look like, of course
  • and then a directory called "legacy", into which I don't even dare look

And that's just a glimpse.

Normally, I wouldn't write a post about something like this... But seriously, can you see the amount of problems with this thing? And it's only from 2005! And from a guy who keeps writing on his blog about how clever he is!

Now tell me: What would you do?

I'll tell you what the people in charge decided to do... Rebuild the whole thing from scratch. Forget it even exists, and start all over again, this time with someone that (hopefully) knows what he's doing (that would be me).

And now, a personal note...

It's always easier to complain and to criticize other's code than doing it yourself.

I would totally understand that one day, the person who built that system would come across this post or something else I'd written about his project, and would come back at me, in a defense of his technical skills.

With that in mind, I'd like to leave a note to that person, regarding how he built this thing:

I dare you to explain what you were thinking and the decisions you took, assuming you took any!

Friday June 27, 2008
01:36 PM

"This Summer in Perl"

Wednesday June 25, 2008
04:22 AM


Next Friday will be my last day at $work.

I'm moving to another job.

That being said, know that my phone number will not be working after Friday around 5pm, and I won't be using my work email address either.

If you need to call me, or if you don't have my personal email address and you want/need it, this may be the time to reach me.

See you around,


Friday June 13, 2008
06:56 AM

Thanks for all the nominations for the White Camels

We got over 20 nominations (I'd call that a success).

I am now compiling all the emails and information and afterwards the discussion and the voting will start.

It's not going to be an easy task, I can tell you that... There's lot of good stuff in those emails :-)

Thursday June 12, 2008
04:57 AM

The streets are empty [Portugal]

It's like a preview of the apocalypse, and all it took was a strike.

The fuel transportation companies are on strike.

You should see the gas stations yesterday. The gas stations, and the havoc.

Most of them were closed, but the few ones that still had some fuel were packed with cars and people shouting at one another.

They all knew there wasn't much fuel left, so every car counted. The cars, and the people carrying cans and bottles.

Late in the evening, one could see parked cars along the freeways. Empty tanks.

This morning, the amount of cars on the road made the traffic lights seem pointless.

And all it took... was a strike.

The government started by saying there was no way they'd give in to the demands.

Maybe they don't really know how fragile a country can be, if you strike in the right place.

Around 5am, the strike was lifted.

The highway tolls will now be cheaper during night time, and other reividications were also met.

The gas stations are now being refueled, and the country should resume its normal laid-back lifestyle pretty soon.

It was... interesting to see.

Wednesday June 04, 2008
05:51 AM

Back from YAPC::Asia::2008 and Japan

I don't even know where to begin...

The whole experience was wonderful, amazing, and fantastic.

I don't think I've ever been to a country that feels so civilized, organized, safe, and polite.

Some people have asked me whether I'd go back to Japan...

Well, my friends...

It's not a matter of "if", it's just a matter of "when".

Some big thank-you's:

The organizers

Miyagawa-san, you guys rock!

The sandwiches and the noodles soup was great, but you guys really went over the top with that fabulous sushi dinner.

The only reason I flew back to Portugal instead of rolling here was because I'd probably end up in Australia (which wouldn't be a bad thing, but $work was waiting for me).

The attendees

I've been very well treated everywhere I've been to, but Japanese people are so very, very polite, and I just couldn't find an exception to this rule.

I also met some Coreans there which made me think this is probably not something limited to Japan, but likely to be the state of mind in a considerable part of Asia.

Thank you so much to everyone.

The speakers

Oh yeah.

The selection of speakers was very, very good.

Thanks, guys. /~ Pleased to meet you... Hope you guess my name... ~/

Marty and Karen Pauley

My wonderful hosts, Marty and Karen Pauley.

You guys were great :-)

There's a place here in Portugal where I go to when I need to find peace of mind.

Your house and company has the same effect. I'd go there more often, if it just weren't so far.

Thanks for taking me to all those places, including Kamakura, Yokohama and, of course, the /(a?)mazing/ Karaoke bar ;-)

Thank you so, so very much.

And I'll see you two again in... Oh, a couple of hours! I have to pick you up at the airport, for the Portuguese Perl Workshop :-)

My turn to be the host :-)

Casey, Chastity and Schwern (who also stayed at the Pauley's)

You guys were great to hang around with :-)

Schwern, if I end up addicted to EVE Online, it's all your fault (and a bit of Adam's too).

Saturday May 17, 2008
11:43 AM

White Camel nominations are now open

Every year, at OSCON, the White Camels are presented.

If you look at the previous winners, you'll notice that these are mostly unsung heroes, like previous awardee Eric Cholet, the human moderator of so many Perl mailing lists, or Jay Hannah, one of the people running (if you ever created/maintained a pm group, chances are that Jay walked you through the process).

Some of these people may be well known, like Allison Randal or Randal Schwartz, while others may be complete strangers to at least part of the globe, like Josh McAdams or Jay. Some of them may be extreme Perl hackers who created the original JAPH, but they actually received this award as a recognition for their community contributions to Perl.

That's not to say a great hacker can't receive the award, but you don't have to be one in order to be eligible.

That being said, the nomination process for the 2008 White Camels is now open.

If you think there's someone who deserves a White Camel, this is the time for you to send in your nominations. Send them to, if possible with a subject along the lines of "White Camel Nomination :: $name". Make sure you properly identify the nominee and tell us why you think that's a worthy nomination.

Don't go thinking "nah, somebody else will do it" because: a) everybody else may be thinking the same, and b) you may state your case differently than the next person.

We'll be receiving nominations until June 11, 2008, by midnight, but don't wait up or you'll forget. Do it now!