Hallo Welt

Test, Test, Test, 1, 2, 3...

Hello World!

This post is a bit of a "Hello World" post to stake my flag in blogs.perl.org.

I'd like to think I can return to writing more technical posts about my perl world - and this blog gives me the clean slate I need to start again.

TPF 2010Q3 Request for Grant Proposals

The Perl Foundation is looking at giving some grants ranging from $500 to $3000 in August 2010.

In the past, we've supported Adam Kennedy's PPI, Strawberry Perl and Perl on a Stick, Nicholas Clark's work on Perl internals, Jouke Visser's pVoice, Chris Dolan on Perl::Critic and many others (just check http://www.perlfoundation.org/grants for more references).

You don't have to have a large, complex, or lengthy project. You don't even have to be a Perl master or guru. If you have a good idea and the means and ability to accomplish it, we want to hear from you!

Do you have something that could benefit the Perl community but just need that little extra help? Submit a grant proposal by July 31.

As a general rule, a properly formatted grant proposal is more likely to be approved if it meets the following criteria

OSCON Call For TPF Volunteers

The Perl Foundation will have a booth at OSCON again this year. We'll need volunteers to help out with:
  • Getting all the swag and banners
  • Setting up the booth
  • Working the booth
  • Talking to conference-goers about Perl projects, the community, and language.
  • Handing out swag
  • Taking down the booth, handling left over swag

If you would like to volunteer, please signup on the wiki:

http://www.socialtext.net/perl5/index.cgi?events_2010_oscon

You should also join the "events" mailing list by sending a message to

events-subscribe@lists.perlfoundation.org

What would you like TPF to do?

As a response to my grant request there were several comments pointing out that it is unclear to some people what TPF does and what it should do. So while I am not a representative of TPF let me ask this question. What would you like The Perl Foundation to do?

I hope that the responses to this question will allow the board of TPF to form their own strategy or at least to ask a better question.

Membership and board:

Currently the bylaws of TPF do not allow membership. Therefore the board is a self-elected group of people. I am not sure if they have a well defined process on how people can get in the board and how board members can get out. (eg. Is there a time limit for being a board member? How can one apply to become a board member?)

Would it be better if TPF was open for membership? Who could be a member?
Anyone? People who are approved by the board?

The Mail Archive

The Mailman archive is not always implemented on mailing lists (although on perl-mongers it is), but often it would be advantageous to have something slightly more accessible, and more importantly something more open to the non-perl community.

I found The Mail Archive some while back which members of certain non-programming groups I am on have found an easy way to keep on top of posts to their mailing lists rather than reading emails mixed in with other emails & having to generally handle them on a daily basis. So I added the za-pm group to this. Now with some posts stacked up you can see how it displays.

Use is simplicity itself, just add archive@mail-archive.com as a member and all else is handled automagically. Put a link on the bottom of every post and you are set for the members to pick it up.

I'm not claiming this is the best such solution, there are others, but it works nicely and the display format is neat. I hope that this will make za-pm more visible to the world both within and without the perl community.

a VIPs YAPC::NA 2010 notes

YAPC::NA 2010 Technology Overview

I am new to the Perl community. This is an overview of the the technology I found interesting in the talks I attended at YAPC::NA 2010 http://yapc2010.com/.

Web

Environment

Rakudo Perl 6 gets into databases

Database access for Rakudo Perl 6 has improved markedly in the past month. Here are the main points:

The MiniDBI project formerly known as FakeDBI is destined for inclusion in Rakudo * and is now 'usable' and 'useful'. Commit permission to the repo is freely available via hugme in #perl6. Porting simple database client software from Perl 5 to Perl 6 requires only minimal editing.

So, why MiniDBI and not just DBI? Because Perl 6 will have a DBI v2, based on JDBC, read more about that below. The Perl 5 DBI (v1) is very widely used, but enhancing it is far less important than maintaining its stability. Mini means a short term port of a v1 subset, leaving the DBI name free for v2 to use in future.

The mysql DBD has been working for several weeks now, most enjoyably inside http://pivo.jnthn.net (source). Su-Shee++ contributed various fetch* methods and tests in the new database independent test suite.

Devel-Platform-Info

A new distribution is now on its way to your nearest CPAN mirror. Devel-Platform-Info provides the code framework to return metadata regarding the currently running operating system. The intention is to eventually use this metadata within CPAN Testers reports. However, the first step is to provide the means to extract the information from the operating system and return it in a consistent form (a hash) to the calling code, regardless of the operating system. There have been a few attempts on CPAN to provide 1 or 2 items of this metadata, or to verify whether the OS is as requested, but nothing that provides a simple data structure, with all the necessary components provided.

Must remember to keep my mouth shut :(

Over the past year I had posted queries to our local perlmongers group za-pm and received substantial help from the inmates.

Looking at things Perl I noted that on the perl.org site that we did not have a flag planted on the map. Querying this I found that the group leader (I never knew there was such a thing) had gone awol and that his emails were bouncing.

Reporting this with glee to the list & asking the leader to please stand up and be identified got me voted into the hot seat before you could write a perl one-liner.

Having disposed of other encumbrous duties I recently got access to the web site and added a small note, the first in seven years! Happy that I had fulfilled my promise to reactivate the site to pm_group I sent a small 'done it' note expecting a pat on the back.

When rand isn't random

In spite of having programming Perl mostly full time for the last 12 years, I still find myself learning new things about how Perl works (like the time I discovered the arcane apostrophe package separator when trying to add a possessive 's' on the end of a variable in an interpolated string).

Yesterday yielded a similar epiphany when I realized how rand, srand and fork were interacting in our e-commerce application at $work. Consider the following one-liner:

perl -le 'for(1..2) { fork or do { print int rand 100; exit } }'

This prints two random numbers between 0 and 99. Simple. Now, consider this slightly different example:

perl -le 'rand; for(1..2) { fork or do { print int rand 100; exit } }'

This prints the same random number between 0 and 99 twice. The reasoning is quite simple but was not obvious to me at first. When rand is first called in a Perl application, srand is implicitly called to seed rand with a different starting number. If this happens prior to a process forking, the same seed is shared by all of the child processes and non-randomness ensues.

Reduce in Perl

Perl has grep/map/sort since probably forever (actually, sort() starts appearing since Perl 2.0). But even now, reduce is still not a builtin in Perl 5 (though available via List::Util), so doing reduce is probably not something that comes as naturally to Perl programmers. Meanwhile Ruby, JavaScript, and even PHP have their reduce operation builtin.

But then, reduce is "not really that useful" (you can just replace it with a simple for loop). So much that Python 3.0 now removes the function from the global namespace and reduces it (pun intended) to a mere member of functools. I guess reduce is really handy only if you are in a heavily functional language that lacks procedural basics.

This can be thought of as a testament to the level of language design skill that Larry has.

The rather funny thing is, in Perl 6, in addition to the reduce() List method there is also the reduce ([]) metaoperator as well.

Monitoring according to roles, not category tags

For a while I've had very little to write because I've had very little time to speak. It makes sense when you think of it. :)

We had a lot of changes at $work recently. I've received a new position (as a team manager) but I'm still retaining my "Perl Ninja" title, and I've also had a birthday celebrated at the $office and was given a makeshift rubberband gun, crafted by Tamir Lousky. :)

Another big change (that is the brainchild of Mr. Lousky) is monitoring according to roles and not category tags, which is (at least according to the title) the subject of this post.

Just another Perl blogger,

Inspired by some conversations at YAPC NA 2010, I'm abandoning my use.perl.org blog, and starting here. I've never used Movable Type before, so this might take some adjustment.

This blog will be primarily about Perl-ish things in my awareness. I have quite a few other publishing realms, each with their own specialization.

If you want to follow everything I post, I suggest subscribing to my FriendFeed feed.

Why a blog?

This is the first blog post I have ever written. Mostly I've not written anything based on fear. Fear that I'm not good enough to post anything out into the aether. 3 years ago I left the programming industry thinking I would never return. In that time I've learned some hard life lessons, the foremost of these lessons is that fear is like a fly trap, it keeps you stuck. So I am making 2010 the year to be fearless. I hope you will all join me and make your first blog post on blogs.perl.org. Look for more posts from this, now community aware, Perl hacker.

grep is your friend

Grep is another Perl's great built in function, one of the things I use it most is to check if I can find an element on a list. For example, instead of something like

    my $found = 0;
    foreach (@list) {
        $search eq $_ and $found++;
    }


I prefer to use something like:

    my $found = grep {$search eq $_} @list;


Code is simpler and more elegant, there's no significant performance from using one or another, although grep seems to actually run faster if you want to squeeze all the crumbs:

My first perl6 code

Like everybody else, I've been reading about Perl6, lurking in #perl6 and just trying to keep up with the progress. But in real life, most of us need to turn out Perl5 code for a living. Of course, we love it (well, I do), but it could be fun to have at least a line or two of Perl6 code under the belt before rakudo *.

So today I tried to jump head first into a problem I wanted solved, connecting to PostgreSQL from Perl6. I'd noticed that there is a Pg.pir in parrot, so I thought it would be possible to use that. It turned out that it is possible, but it required a lot of guessing and even more help from #irc (mainly moritz, who also identified and fixed (r47900) a bug in Parrot in a matter of minutes). omg people are helpful there!

Is it just me?

My Perl Android talk was accepted to YAPC::EU 2010 (!!!!) and I want to book the room reservation for my girlfriend and I.

Unfortunately, the hotel (MyHotel - where the conference is taking place) only accepts the credit card details via Email. I've suggested simply calling them and - once I've verified that I'm speaking to the right person - give the details via phone.

However, they insist on getting it via Email. They even suggesting sending two emails, one with half the details, the other with the rest of the details.

Now.. is it just me or is sending it via Email completely insecure? Not to mention that separating them into two emails provides no added security whatsoever.

How did other people handle this? Do you think I should send it via Email, or book another hotel, or.. persist?

Parsing Perl 2: Down the Garden Path

The Garden Path

In Perl 5.10, the following code is a syntax error:

{42;{1,2,3;4}}
If you try it, what you'll see is something like this:
syntax error at (eval 25) line 1, near ";4"
syntax error at (eval 25) line 1, near "}}

TPP is based on an algorithm called LALR. (To avoid confusion when discussing various programs which parse Perl, I will call the one that comes with the Perl distribution the Tradition Perl Parser, or TPP.) If you look at perly.y, you will find a real achievement in LALR parsing. and therefore in computer language parsing in general. But LALR has its limits and even in the TPP these show up every now and then.

Authenticating Proxy Pain

Having just finished an enormous pile of marking, but not having enough time to get on with something more substantial I thought I'd work out (again) how to use LWP::UserAgent and WWW::Mechanize behind an authenticating proxy.

Sometimes you're lucky and a proxy url of the form
http://user:pass@my.proxy.server:8080
will work nicely. No such luck for the proxy I usually use.

Anyway, here's the way to use LWP::UserAgent behind an authenticating proxy:


use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my ($user, $pass) = qw/user pass/;
$ua->proxy(['http', 'ftp', 'https'], 'http://my.proxy.server:8080/');
my $req = HTTP::Request->new('GET',"http://www.google.com");
$req->proxy_authorization_basic($user, $pass);
my $res = $ua->request($req);
print $res->content;

And here's how to do it with WWW::Mechanize:


use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
my ($user, $pass, $proxy) = qw(user pass http://my.proxy.server:8080 );
$mech->credentials( $user, $pass);
$mech->proxy('http',$proxy);
my $url = 'http://whatsmyip.net/';
my $response = $mech->get($url);
print $mech->content;

I'm not really sure how you'd go about accessing a basic auth protected page with the WWW::Mechanize method mind you. It'd also be nice if (in both cases) whether to use a proxy, and the username and password could be handled during the call to
->new
.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.