August 2010 Archives

The Foursquare gaming code challenge

Mayank Lahiri writes a Foursquare checkin tool in nine Perl statements, and Alex Ford says he has a two line solution, where line means statement, and statement. Part of the reason their solutions look so ugly is that they want to do it with the Standard Library. I was slightly interested in this because someone had asked Randal if he was checking in with Perl (he is not).

Larry Wall once said that he could program anything in one-line of Perl given a sufficiently long line. That is, in a language where lines aren't significant, line count is stupid. If you want to count lines, Python is probably your language.

Faking a Foursquare checking is not straightforward with LWP, which actually makes this problem a little more interesting. The Foursquare API uses either Basic or OAuth authorization, but it doesn't think about web browsers. It figures that your application doesn't need a prompt (i.e. a 403 response) for an authorization header, so there is no authorization realm. This means that LWP's credentials method is useless. However, I can use the add_handler method to fix up the request to force the Authorization header:

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;

# The Foursquare API doesn't have a 403 response, so it has
# no realm. This means I have to force the authorization
# header.
    request_prepare => sub { 
        my( $request, $ua, $h ) = @_;
        $request->authorization_basic( @ENV{ qw(FOURSQUARE_USER FOURSQUARE_PASS) } );

    Content => {
        vid     => $ARGV[0] || 8212918,  # The Perl Review
        private => 0,
        geolat  => $ARGV[1] ||  42.01974,
        geolong => $ARGV[2] || -87.67446,

My script isn't exactly the same as theirs, though. I'll let cron handle the other details.

I'm going to Tokyo in December

I'm going to be in Tokyo from December 5 to 10. I realized that if I could make it to somewhere in Asia before the end of the year, I will have been on every continent in 2010. Not only that, I hear the Shibuya Perl mongers not only have the largest YAPC, but also have to turn people away just because it's so popular (tickets are on sale now). I want to see what's going on there, even if I can't show up in the right month.

So far I have no plans, although Karen Pauley might find somethin…

YAPC::EU 2010 videos are on YouTube

The YAPC::EU 2010 team has uploaded to YouTube videos of the conference in the yapceu2010 channel. There's even one of me presenting the White Camel Awards to cog and to Barbie. I don't think I'm terribly interesting, but I like their comments as they accept their awards.

Paul Fenwick couldn't be there, but maybe someone can convince him to do a video acceptance speech. He's dressed as a Star Fleet officer, a pirate, and a mad scientist. What should he be in the video?

Which Perl XML module should I use to ...?

I asked Which Perl XML module should I use? on O'Reilly Answers to survey people about their XML module use, but my question was too general. Before you can recommend an XML module, you need to know what the task is.

I've refined the question into three more specific questions:

Maybe someone should start the same sort of questions for Perl web frameworks or any of the other topics that have multiple (hence, confusing) options.

Which XML module should I use?, on O'Reilly Answers

O'Reilly Answers has an interesting, new poll feature. I've asked Which Perl XML module should I use?.

The Perl activity on O'Reilly Answers has been a bit low, but with a little work, we can get it back up there along with the other topics on the front page.

And, unlike other sites, you can actually redeem the points you earn on O'Reilly Answers for valuable things like books and conference passes. Perl monger group leaders, speakers at O'Reilly events, and people in the book review blog program get starter points just for signing up.

Please test Crypt::SSLeay

Sinan Ünür is preparing a new release of Crypt::SSLeay, and he's been applying all of the patches in its RT queue. He's getting pretty close to a release version, so if you depend on this module, please have a go at one of the developer versions.

I've only been indirectly involved with Crypt::SSLeay development by making sure people can work on it and sometimes convincing people to help out, so I'm really happy that Sinan is helping out. This is an important module for Perl since a lot of that fancy stuff we do with LWP (and things built on LWP, such as WWW::Mechanize). It's a tricky thing to get right because it has to track openssl and figure out where to find that on your system. Even though we have CPAN Testers, sometimes checking yourself is useful.

The 2010 White Camel Awards

This year, on behalf of Perl mongers and O'Reilly Media, I present the White Camel Awards at YAPC::EU in Pisa.

The White Camel Awards recognize significant, but non-technical, achievement in the Perl community, traditionally in three areas: Perl advocacy, Perl user groups, and Perl community. Non-technical work tends not only to be thankless jobs which nobody praises in public. However, these people keep doing the work despite the possibility or reward or recognition. Curiou…

My continuing dream of a Perl XML(::Twig) cookbook

I ran into Michel Rodriguez at YAPC, so I started talking to him about my idea for an XML::Twig cookbook. I really, really love his module and want more people to use it. It takes a bit to get used to, so I think it's ideally suited for some cookbook-style documentation.

His advice is that XML::Twig is what you use when parsing and futzing with XML is not the primary purpose of your program (e.g., you have some config files to read). That turned into a bit of a discussion with those around us about when you should use which XML modules, and that we should answer the same cookbook reci…

Do you want extra Effective Perl in Safari Books?

I posted this at The Effective Perler too. Josh and I are thinking about adding some bonus content for Effective Perl Programming in Safari Books if people think it would be worth it. We don't know how many people read our stuff in Safari Books.

Also, if we end up thinking that's a good idea, what would you want the bonus content to be?

How to write about Perl 6

YAPC::EU is about the Renaissance of Perl (although Eddie Izzard wonders why the Italians gave the real one a French name), and like the original, that's the time for an explosion of information and exchange of that information.

I have a few suggestions for people who want to promote Perl 6 by writing or speaking about it. I've had these complaints about Perl 6 articles people wanted to put into The Perl Review, but from the summer conferences this year I've been hearing the same complaints from other people. I've also had these same complaints about my own Perl 6 talks (which …

About brian d foy

user-pic I'm the author of Mastering Perl, and the co-author of Learning Perl (6th Edition), Intermediate Perl, Programming Perl (4th Edition) and Effective Perl Programming (2nd Edition).