Blog entries tagged with "perl"

Bugs and Melbourne Perl Mongers

Monday, December 7th, 2009 at 09:10pm

At two Melbourne Perl Mongers meetings this year Paul Fenwick co-opted us into fixing bugs.

Melbourne Perl Mongers Bug Squash (September 2009)

Our first attempt was against the Volatile 100. It wasn’t very successfull, but we did all learn a lot about how to read the CPAN testers reports. The problem we had was that the Volatile 100 is made up of the modules that are depended on the most. As such these are already well tested and the reports that we were looking at where for quite unusual bugs.

Melbourne Perl Mongers Bug Squash (01)

Melbourne Perl Mongers Perl 5.12 bug triage (November 2009)

Our second attempt was at first hindered by problems with the wireless network, but that just meant we had to head over to the pub that had free wifi. This time we were a lot more successful as all we were doing was triaging new bug reports against Perl itself. 5.12 bug triage (10)

Now I am looking forward to the meeting this week where Damian Conway will be presenting The Missing Link.

Tagged with: ,

Should I try to be an Iron Man?

Thursday, April 30th, 2009 at 09:27pm

A bit over a week ago I heard about Matt Trout’s proposal to get more people blogging about perl on a regular basis: We Are Iron Man. Basicially if you post about perl once a week (on average) for six months you qualify as an Iron Man.

An announcment without the swearing can be found courtesy of the Enlightened Perl Organisation.

It looks like this is gaining quite a bit of momentum as I have heard about it from quite a few different sources and there is a Planet Iron Man to show that there are quite a few contenders so far.

Should I enter?

I don’t know. While I should be able to keep up with the schedule, I’m not sure about the content as I don’t know what I have to say about perl.

To see what I have said that is remotely perl related, check out my blog posts tagged with perl. Not that much is there?

Tagged with: ,

Sorting in PHP is extra effort … and there is no spaceship

Monday, March 2nd, 2009 at 10:47pm

Tonight I have been hacking in PHP on wp-lifestream in order to get grouped events ordered by time. I say hacking because there is a lot of PHP I don’t know and I don’t fully know how wp-lifestream is arranged.

When I first looked into sorting the grouped events my initial thought was to do it when the group was rendered. However that involved sorting data structures, so I decided that it would be easier to perform the sort when they were retrieved from the database. This is the change I made, and I thought it had worked.

Earlier today I found that while it worked when a feed was refreshed, it didn’t work when the group was updated after an event was deleted through the interface (I uploaded one too many photos to Flickr, which I later remved). So I had to turn back to the rendering code.

A var_dump() (Perl people should think Data::Dumper) later I knew what I was dealing with: an array of associative arrays that represented each item in the group. The relevant keys being date (in seconds since epoch) and title.

If this were perl it would be an array of hashrefs and I would have sorted it like this:

@events =
    sort { $a->{'date'} <=> $b->{'date'} || lc $a->{'title'} cmp lc $b->{'title'} } 

Not so in PHP:

  • PHP sort functions sort the array in place instead of returning a new list
  • The more advanced PHP sort functions take a callback to use instead of a block
  • I’m not using PHP 5.3 so there are no closures yet, but at least anonymous functions can be created with create_function()
  • PHP does not have a spaceship operator (<=> for numerical comparison), even though there are equivalents of cmp (strcmp, strcasecmp).

This is what I ended up with:

    create_function('$a,$b', '
        if ( $a["date"] == $b["date"] )
            return strcasecmp( $b["title"], $a["title"] );
        return ( $b["date"] < $a["date"] ) ? -1 : 1;

To me the logic is all messed up. Because there is no <=>, it needs a == comparison first. In the usort examples this returned 0, but gave me a convenient place to call strcasecmp() for the secondary sort. But that is breaking one sort into two statements and mixing in the other sort. It works and appears to be the PHP way of doing things, but it looks wrong to me.

(And yes, create_function() takes a string. Shudder…)

Tagged with: , , , ,

A correction to my paper from OSDC2006

Thursday, November 22nd, 2007 at 07:01pm

In my paper at last year’s Open Source Developers’ Conference I said that one of the negatives of Class::DBI was that it connects to the database at module load. If this fails an exception is thrown which can cause issues when the Class::DBI code is just one part, for example in a web server.

It looks like we were causing this behaviour, instead of it being how Class::DBI operates.

By default DATE fields in Oracle are formatted for year, month, and day even though the field includes hour, minute and second. In order to get the complete date and time our base class changes the default formatting with a line similar to:


It is this line that triggers a connection on module load. If it is removed then the classes can be loaded even if the database is dead. Connection is now only attempted on first action which is a much more approriate time.

I’m not sure what the documentation said about it when we put the line in, but Setting Session Globals and Working With Oracle Date Fields on the Class::DBI wiki warn about using it in a mod_perl environment and that it will initiate a connection when the modules is used.

Over the next few days the commercial product that this database is used with is being upgraded. During this time the database will be unavailable for use so we revisited the issue of how to get the classes to load cleanly. These investigations found the root cause and we now have a solution; alter the base class so that the date formatting is altered whenever a connection is initialized (using information from how to use multiple databases), not when the class is loaded.

Now, although we have solved this issue, having to solve it wasn’t trivial as we were required to dig through some of the Class::DBI and Ima::DBI internals to mimic its behaviour.

Tagged with: , , , ,

Lessons in procrastination

Thursday, October 11th, 2007 at 07:19pm

Last night’s perl mongers meeting (actually an OSDClub meeting) featured two examples of less than ideal organisation.

Paul was up first with a walkthrough of how an online todo list (specifically Hiveminder, but also Remember The Milk). It was then ironic that Paul had not actually finished preparing his presentation. A while ago I had looked at Hiveminder (when Paul sent me a task) and I didn’t get far. Now that I have seen more of what it can do I should give it another look.

The second talk was supposed to have been from Rick about integrating with Jaiku. However, since he was planning an online walkthrough of what he has done instead of an actual presentation he neglected a crucial step: checking ahead of time that he would have an internet connection. Fortunately he did give a brief overview of how he is using microblogging, including as a means of documenting projects, which was then a topic of discussion at the pub.

Speaking of the pub… Last month they messed up our orders so this time we went down the street to a different one, the Redback Brewery Hotel. Overall it was good, not as crowded, not as loud, and not as dark. They did mess up one of the orders, the brought out a pie instead of a steak sandwich, but they noticed it straight away. More importantly they apologised and brought the correct meal out as soon as they could. Approved.

Tagged with: , , ,

Damian makes my head hurt…

Monday, September 12th, 2005 at 06:23pm

… but in a good way.

Today was my first of four days with Damian Conway. Today was the first day of Advanced Module Interface Techniques and so far he as led us through the design and some of the implementation of ‘magic’ (aka sufficiently advanced technology) modules such as Perl6::Say (stunningly simple) and Contextual::Return (simple to use, mind bending to understand the implementation).

Tomorrow will be the second day of this course which is then followed by The Productive Programmer and Advanced Technical Presentation Techniques (one day each).

Damian will also be giving his “Fun with Dead Languages” talk at Melbourne Perl Mongers this Wednesday…

Tagged with: , , ,

Interesting talks…

Sunday, October 17th, 2004 at 02:08pm

Mark Jason Dominus, the author of Conference Presentation Judo, also has the slides for a number of his other talks available.

Some of the more interesting ones (to me at least) are:

Tagged with: ,

Perl Best Practice

Monday, May 24th, 2004 at 06:06pm

Today was the first of two days of having Damian Conway in at work to present his Perl Best Practice course.

So far most of what we had been arguing over at work for at least the last six months was ratified by Damian.

Tagged with: , , ,

PAUSE account. Woo!

Saturday, May 1st, 2004 at 07:10pm

Um, yeah…

I finally got around to applying for an account on the Perl Authors Upload SErver. I suppose now I have to actually finish some of the things I have started, such as a subclass of News::Newsrc, and upload them to the CPAN…

Tagged with:

Advanced Object-Oriented Perl

Thursday, April 29th, 2004 at 07:39pm

Damian Conway‘s Advanced Object-Oriented Perl course is excellent and now I can’t wait until the end of May when we will be getting him back again, but that time for Perl Best Practice.

The best thing about Damian’s courses is that we can delve deep down into some very elegant and powerfull constructs that have practical applications. Right now I want to write a class that uses a closure to implement a flyweight pattern in order to enforce data encapsulation…

I also want to do his Advanced Module Development Techniques, or as Damian referred to it "Scary Perl", course…

Tagged with: , , ,

Regular Expressions training

Friday, October 24th, 2003 at 10:53pm

Today at work we had Damian Conway in to present his Understanding Regular Expressions course. Overall it was good even though we only covered half of the material. This was because Damian would often talk about fundamental aspects of Perl related to his examples. So while that detracted from the regular expressions it added a great deal more.

A some stage we need to do his Perl Best Practice course, assuming he has finished planning it…

The course also brought back memories of having Damian as my lecturer for a couple of subjects back in my early years of university. His Object Oriented Perl book also brings back memories of similar concepts, except in C++ back then. I must finish reading it a some stage…

Tagged with: , , ,