• Devel::NYTProf is the hot new profiler in town

    Adam Kaplan has released a cool new profiling tool, Devel::NYTProf. It's apparently taken the formatting beauty of Devel::Cover, the code test coverage tool, and used it to identify hotspots in your code. The results are beautiful: Overview and module-level detail. There's also a report writer that provides CSV output and lets you create your own output in your own format.

    I ran into a divide-by-zero error that I patched in my local copy, but other than that the results seem good. I look forward to whatever other improvements come. I'm also glad it's been released with the support of the New York Times.

  • The worst way to shorten names

    Dropping vowels to shorten names is a terrible practice. Quick, someone give me an idea what $hdnchgdsp means, an Actual Variable from some Bad Code I'm working on today.

    It's not just variables names, either. Filenames often need to be shortened, but dropping vowels is not the way to do it. You're left with unpronounceable names that are annoying to type.

    The key to effective abbreviation is not removal of letters from the middle of the words, but from the end. Sometimes, it doesn't make sense to shorten a word at all, like "post". If you have a file that is supposed to "post audit transactions", call it "post-aud-trans" or "post-aud-trx", not "pst_adt_trns".

  • Perl Foundation needs new members

    The Perl Foundation needs new blood. Jim Brandt writes:

    Have you ever wanted to get involved in The Perl Foundation, but didn't know how? Well, now's your chance. I'm pleased to announce open self-nominations for the following TPF roles:

    You can follow the links above to read descriptions of each of the positions. If you think you're a good fit for one or more of them, send me an email at cbrandt at perlfoundation dot org. I'll then invite you to a dedicated wiki we have set up just for the election.

    Once you join the wiki, you'll set up a page to post all of your experience and answer the questions provided in each section above. The wiki is private, but you'll be able to see the other candidate pages, and they'll see yours.

    The deadline to get all of your information in is midnight next Tuesday, March 11. Our committees elect their members, so the Conferences Committee will be voting on the CC chair and the Steering Committee will vote on the chair and PR positions. After we have a chance to look over everyone's information, we vote and select our newest members.

    You only have a week, so don't wait too long. I look forward to hearing from you.

    Karen Pauley is stepping up to run for Steering Committee chair, so how about you? Maybe that's a spot you'd like to work on, or maybe public relations is more up your alley. This is your chance to help lead TPF lead Perl and Perl development.

    Astute followers of TPF will note that the PR spot is open, a spot that I once held. Yes, I am no longer doing PR for TPF. I've done that job for a while, and now I'm moving on to do other things, not least of which is this little news called perlbuzz.com.

  • Sign up to help with Summer Of Code

    Google's Summer Of Code is upon us again. The Perl community has had some problems in years past with lack of organization, and the SOC mentors seem determined to not let that happen this year. Eric Wilhelm posts:

    TPF needs volunteers to make summer of code happen this year. It sounds like the administrators got stretched too thin in 2005 and 2006, and we really didn't have ourselves together in 2007. So, I'm proposing a departmental structure under a TPF umbrella, which will localize the cat-herding effects within various large projects (so far, parrot and Catalyst appear to be on board with this.) I would like to demonstrate that we have our act together this year, so we need to get a solid pool of administrative volunteers and mentors together before the 8th.

    Eric says that they need a backup administrator, to minimize the reliance on a single person; department heads for p5p, "modules", etc; suggestions about department structure, and plenty of mentors.

    What does a mentor do?

    • Act as a point-of-accountability for Google
      • keep tabs on your student
      • prod the student for updates
      • fill-out midterm and completion evaluation forms
    • Take the student under your wing
      • get them participating on mailing lists, IRC
      • make sure they know where to go for help and resources
      • answer questions about the bugs in the social machine
    • Represent the community
    • Get a t-shirt

    If you'd like to help, or have ideas, contribute at one of these three pages:

  • Good Perl code is the best form of evangelism

    Here in the Perl echo chamber, there's a lot of talk about advocacy and getting people to use Perl and whether Perl is more popular in the job market than PHP, but I think most of that is just wind in sails. We talk and talk and talk but when it gets down to it, people don't use Perl because it's bigger in the job market, or because of a well-argued thread on Slashdot. People use Perl because the power of Perl makes their lives easier.

    Back on the 17th, I posted that Perl would be allowed in the Microsoft Scripting Games. Now, I'm no friend of the "scripting" moniker, but I was glad it was allowed in and thought maybe there would be some good visibility for the power of Perl.

    Then I saw the results.

    Event 2 in the competition was to read in a text file of comma-separated values of ice skating scores, drop the high & low scores from each skater, and show the top three skaters and their average scores. Trivial for Perl, right? The solution that Microsoft posted, however, was effectively a VBScript script translated to a Perl program (by their own admission).

    Here's the solution they posted.

    %dictionary = ();
    open (SkaterScores, "C:\Scripts\Skaters.txt");
    @arrSkaters = <SkaterScores>;
    close (SkaterScores);
    foreach $strSkater (@arrSkaters)
    {
    $intTotal = 0;
    @arrScores = split(",",$strSkater);
    $strName = @arrScores[0];
    @arrScoresOnly = (@arrScores[1],@arrScores[2],
    @arrScores[3],@arrScores[4],
    @arrScores[5],@arrScores[6],@arrScores[7]);
    @arrScoresOnly = sort({$a  $b} @arrScoresOnly);
    $intTotal = @arrScoresOnly[1] + @arrScoresOnly[2] +
    @arrScoresOnly[3] + @arrScoresOnly[4] +
    @arrScoresOnly[5];
    $dblAverage = $intTotal / 5;
    $dictionary{$strName} = $dblAverage;
    }
    $i = 0;
    foreach (sort {$dictionary{$b}  $dictionary{$a} }
    keys %dictionary)
    {
    $i++;
    print "$_, $dictionary{$_}n";
    if ($i == 3) {exit}
    }
    

    Just dreadful. Among the atrocities: Stringing together list elements with plus signs to get a sum; Hardcoded array indexes; Hungarian notation prefixes of variables, in addition to the Perl sigils; breaking out of a loop after three records are shown, rather than starting with a list of the top three. It's just not good idiomatic Perl code.

    Perl's arrays and hashes are powerful, and underused here. Perl arrays are treated like C arrays.

    In a few minutes, I had put together the following program which is shorter and clearer because it takes advantages of Perl's strengths.

    use warnings;
    use strict;
    my %averages;
    open( my $SCORES, '<', 'c:/scripts/skaters.txt' )
    or die "Can't open score file: $!n";
    while ( <$SCORES> ) {
    chomp;
    my ($name,@scores) = split ',';
    @scores = sort @scores;
    # Drop high & low scores
    pop @scores;
    shift @scores;
    my $total;
    $total += $_ for @scores;
    $averages{$name} = $total/scalar @scores;
    }
    close $SCORES;
    my @names_by_score =
    sort {$averages{$b}  $averages{$a}} keys %averages;
    for my $name ( @names_by_score[0..2] ) {
    print "$name: $averages{$name}n";
    }
    

    (I'll admit I haven't tested it against their sample data because their sample data is only available in a self-extracting .EXE, which is a bummer for us non-Windows folks, no?)

    After I wrote my solution, I noticed that they have an Experts Page that includes links to solutions offered by Jan Dubois of ActiveState. No surprise, Jan's solution is exemplary Perl, and I'm glad that Microsoft provides it. My frothing subsided a bit after discovering this.

    Rather than arguing with non-Perl people about which language is better, let's show them. Even more, let's show the people who think that Perl is only a scripting language, only for web sites, or can't be deciphered that Perl will make their lives easier if they'd only open their Swiss Army knives beyond the first blade.

  • How not to do a Changes file

    Here's how to not do a Changes file:

    http://search.cpan.org/src/FELICITY/Mail-SpamAssassin-3.1.5/Changes

    That tells me nothing about whether I want to upgrade my SpamAssassin install. :-(

    Oh, look, I wrote about this before, and how great Tim Bunce's Changes files are.

  • Popular Perl packages in Debian

    Bryan O'Sullivan has a blog entry where he lists popular Perl packages, based on the popularity of the Debian package.

    Not surprisingly, it looks a lot like The Phalanx 100 I came up with a few years ago.

  • Submit talks for YAPC::Asia and Italian Perl Workshop

    YAPC::Asia is fast approaching (May 15-16) as is the deadline for talk submissions, just a week away. Interestingly enough, they're accepting JavaScript talks as well as Perl. I like some good homogenization of the communities! Details at http://yapcasia.org/.

    The fourth Italian Perl Workshop will be September 18th and 19th in Pisa. Organizers are calling for talks, but haven't yet set up the website.

  • The rules of Optimization Club

    From David Fetter's page at http://fetter.org/optimization.html:

    1. The first rule of Optimization Club is, you do not Optimize.
    2. The second rule of Optimization Club is, you do not Optimize without measuring.
    3. If your app is running faster than the underlying transport protocol, the optimization is over.
    4. One factor at a time.
    5. No marketroids, no marketroid schedules.
    6. Testing will go on as long as it has to.
    7. If this is your first night at Optimization Club, you have to write a test case.

    Of course it's company policy never to imply ownership of a performance problem. Always use the indefinite article: "a performance problem", never "your performance problem."

  • Perl debuts in the Microsoft 3rd Annual Scripting Games

    Jan Dubois posted about Microsoft's 3rd Annual Scripting Games, where you can win prizes for writing Perl programs to solve programming problems like "find a word that you can make out of a phone number," and "count the number of characters in a given text file."

    I'd enter if there were interesting prizes, but all the prizes for Windows-only software packages. :-(

  • R.E.M. releases videos under Artistic License 2.0

    You may be hearing murmurs about this, so by my reckoning it falls on me to document it. R.E.M. have taken a stand by releasing the videos from their new album under Artistic License 2.0. The Artistic License 2.0 is a product of the Perl Foundation, and is the license under which Perl is released.

    Normally creators have turned to Creative Commons for movies & music, so it's interesting to see R.E.M. buck the trend and use Artistic License. This can only help the visibility of open source. I'm glad that of all the licenses out there, they chose the one I love. Maybe there'll be a point in the future when Artistic 2.0 is used everywhere, that it will be automatic for the people who create music to think of TPF's license.

    (Please send complaints about R.E.M. references to the dead letter office /dev/null.)

  • Interviews with Michaud &#038; Dice

    Here are a couple of interviews for your reading enjoyment. Patrick Michaud talks about Perl 6 in advance of FOSDEM '08, a conference in Brussels. The interview is a bit old, pre-dating the naming of Rakudo.

    In the second interview, Richard Dice talks about his 14 years with Perl, and current news about the Perl Foundation.

    You know, I'm guessing there's other good content in $foo perl magazin, but since Richard's interview is the only thing in English, it's going to have to stay at the guessing stage.

  • Annoyance-driven development

    "I practice annoyance driven development. I set my threshold of annoyance low such that everytime I feel frustrated by a technical limitation, I notice consciously. My intent is not to find technology endlessly frustrating (though that happens sometimes), but so that I can identify the next most important thing to fix."

    -- chromatic, in "What You Test Changes How You Test"
  • Submit your talks for Chicago and Braga

    Josh McAdams has announced the open call for participation for YAPC::NA in Chicago, June 16-18th, 2008. Talks can be 20, 45, 70 or 95 minutes long, plus the call for lightning talks will open later. The YAPC::NA website has details.

    Across the Atlantic in Braga, Portugal, José Alves de Castro has announced the call for participation for the Portuguese Perl Workshop 2008, June 6 & 7th.

  • rt.cpan.org gets speed improvements

    Jim Brandt announced over in the Perl Foundation's blog that rt.cpan.org got some much-needed speedups. Even though TPF was considering forking over some dough for hardware upgrades, Jesse Vincent and his team managed to speed things up with software only.

  • Leopard cheat sheet

    Here's a handy little cheat sheet for Mac OS X Leopard from O'Reilly. I didn't realize there were so many Finder shortcuts! Command-T puts something in the sidebar! Command-Shift-G lets you type in a folder name! Cool!

  • The perils of Perl 5's indirect object syntax

    Perl lets you call object methods in two different ways:

    • $obj->method()
    • method $obj

    The latter form is usually called only for things like clone $obj, which is pretty ugly. For more about indirect object syntax and some of the pain it causes, see When Is Backwards-Compatibility Not Worth It?.

    It's funny that Max posted that blog entry the other day, because I just was shown a problem that was caused indirectly by it. Mike O'Regan showed me some code that he was surprised even compiled, because it certainly wasn't working.

    sub custom_sort {
    return
    $a->{foo} cmp $b->{foo}
    ||
    a$->{bar} cmp b$->{bar}
    }
    

    See the a$ instead of $a? Yuck. But it compiles just fine. Why? Well, let's see what B::Deparse decompiles it out as:

    $ perl -MO=Deparse foo.pl
    sub custom_sort {
    return $$a{'foo'} cmp $$b{'foo'} || $-->a > {'bar'} cmp $-->b > {'bar'};
    }
    foo.pl syntax OK
    

    Turns out that it's calling method a on the object $- and then seeing if that is greater than {'bar'}. Double-ugh.

    Perl 6 still has indirect object syntax, but you must follow it with a colon, as in method $obj: @args. Larry says in Perl 6 it's completely unambiguous.

  • Tell us how to do it, Andi!

    Andi Gutmans, founder of Zend which drives PHP, takes a swipe at Perl 6 in this interview:

    So we are anticipating a long rollout cycle for PHP 6, and we did not want to take the same route that the Perl project did, with project contributors still working on Perl 6 I think six years later. People make fun of Microsoft, but take a look at Perl 6. . . .

    Sure, PHP 6 may have a shorter release cycle than Perl 6 has, but at the end of it all, we'll have Perl 6, and you'll still have PHP.

    Just sayin'.

    xoxo,
    Andy

  • How to: Find all modules used in a tree

    On the perl-qa list tonight, we were discussing how best to find all the modules used in a source tree. To do the job right, you'd have to run the code and then look at the %INC:: hash, which shows the paths of all modules loaded. The low-tech and usually-good-enough solutions we came up with use ack:

    $ ack -h '^uses+(w+(?:::w+)*).*' --output=$1 | sort -u
    

    Thanks to Andy Armstrong for coming up with a better regex than mine, which assumed that the use statement would necessarily end with a semicolon.

  • Genealogy, web services and Perl

    FamilySearch, the world's largest repository of genealogical resources, announced its 2008 FamilySearch Developers Conference.

    The newly released FamilySearch Family Tree API and soon-­to-­be-­released Record Search API will be main topics of discussion. Other popular topics will be how to read, write, combine, separate, and synchronize with new FamilySearch online resources, developer keys, tree cleaning, GEDCOM, and PAF.

    Genealogy these days is all about lots of data mangling, web services, big databases: it's an ideal area for Perl to work in. Paul Johnson's Gedcom module has long been used to handle GEDCOM files, the standard interchange format for genealogical data.

    I chatted with Pat Eyler about the FamilySearch project, of which he's a member:

    "World's largest repository of genealogical resources" only tells part of the story. Imagine this:
    1. all of the microfilmed genealogical records that the LDS church owns made freely available
    2. a framework for indexing these (or any other genealogical images someone wants to donate)
    3. a unified database of individuals and relationships with varying levels of access control, available to anyone through a rich web client or through web services
    Billions of names, petabytes of image data, and the tools to access and use all of it.

    There's quite a bit of data here for the examining. Even if you're not interested in the conference, check out what's going on with the data. It seems to be an ideal dovetail with the open source community.