このページは大阪弁化フィルタによって翻訳生成されたんですわ。

翻訳前ページへ


blogs.perl.org ― blogging the onion
The Wayback Machine - http://web.archive.org/web/20140922033843/http://blogs.perl.org:80/

Support the "Fund for Act development"

I just announced that the patch -p2 hackathon in Lyon will have a special focus on Act. To support the people hacking on Act and willing to attend this and other future Act hackathons, the French Perl Mongers have decided to setup an Act fund.

patch -p2

The next edition of the French Perl Hackathon (a.k.a. patch -p2), will be held in Lyon, from November 27 to November 30, 2014.

Logically And Yourself (&&=)

I ran into a situation today where I was trying to see whether any exceptions were thrown when evaluating a list of objects. In this particular case I didn’t want the exceptions to short circuit the loop, I just needed to know if any were thrown as we iterated over the list. So I wrote this benchmark to see which of two approaches would be faster.


use strict;
use Ouch;
use Benchmark qw(:all);

my @list = (1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,0,0,1,1,1,1,1,1,1,0,0,1,1,1);

timethese(10000, {
    '&&=' => sub {
        my $is_proofed = 1;
        foreach my $x (@list) {
            $is_proofed &&= eval { $x ? 1 : ouch(500, 'bad stuff') };
        }   
    },  
    '$@' => sub {
        my $is_proofed = 1;
        foreach my $x (@list) {
            eval { $x ? 1 : ouch(500, 'bad stuff') };
            if ($@) {
                $is_proofed = 0;
            }   
        }   
    }   
});   

The more exceptions I introduce to the list the worse the $@ approach got, but the &&= approach remained consistently fast. Here are the Benchmark results with just 2 exceptions in the list:

First Perl::Dancer conference soon

About two weeks till the first Perl::Dancer conference starts!

Schedule will be released on Monday with speakers from Dancer, DBIx::Class and Interchange, notably Sawyer X and ribasushi.

There is still time to sneak in a presentation, hurry up! If you want to speak or simply attend, please register at our website

Token - Elasticsearch Analyze API

Yesterday we looked at an example of how to both index and search using elasticsearch. Today, we'll talk a little about what takes place during indexing, particularly tokenization. For example, what happens when we tokenize the phrase:

porros amb bas?lmic

To find out we can pass the phrase to the elasticsearch analyzer API like so:


curl -XGET 'localhost:9200/_analyze?tokenizer=standard' -d 'porros amb bals?mic'

Here we are using the standard (default) tokenizer which results in the following output:

{
  "tokens" : [ {
    "token" : "porros",
    "start_offset" : 0,
    "end_offset" : 6,
    "type" : "<ALPHANUM>",
    "position" : 1
  }, {
    "token" : "amb",
    "start_offset" : 7,
    "end_offset" : 10,
    "type" : "<ALPHANUM>",
    "position" : 2
  }, {
    "token" : "bals?mic",
    "start_offset" : 11,
    "end_offset" : 19,
    "type" : "<ALPHANUM>",
    "position" : 3
  } ]
}

Notice that we receive three tokens which are the original individual words unchanged. What if I'm some poor american that wants to search on bals?mic but doesn't know how to create an accented a, and instead just inputs balsamic. With the current state of the index, this will not result in a match. ASCII folding to the rescue...

Understanding Behavior Driven Development

I think I'm on the verge of drinking the Cucumber flavored Kool-Aid, which is odd because I've never done Behavior Driven Development (BDD) before. If you've followed my blogs over the years, you know that I am happy to investigate new trends, but at the same time I'm deeply, deeply suspicious of them. BDD has been one of those "fads" that I've been suspicious of, but I think I've changed my mind. What follows is why.

Sometimes Agile Can Hurt Your Company

I've been rather quiet lately because I'm busy, busy, busy. Part of this is contract work for a company (amongst other things, I've been doing building sqitch setup for them), and part of this is new research into Agile. Today I wrote a quick blog post explaining one of my pet peeves about Agile: people say it's not a silver bullet, but they don't say why. I briefly explain when you should and should not use Agile.

Encourage user participation via a single-line patch to your dist metadata

If you have been browsing MetaCPAN lately, you may have noticed a new shiny red ball ribbon on the left side of some distibution pages. What you may not have realized is that this is a generic feature, and you can add one to your distribution just as easily.

TL;DR: All you need to do is add an IRC resource to your metadata:
  • For Meta2.0 (META.json):
      ...
      "resources" : {
        "x_IRC" : "irc://irc.perl.org/#name-of-your-channel"
        ...
    
  • For Meta1.4 (META.yml):
      ...
      resources:
        IRC: irc://irc.perl.org/#name-of-your-channel
        ...
    

And that's it! Note that not only irc.perl.org but any IRC network (including irc.freenode.net) is supported.

For the curious the current logic picking apart this part of the dist metadata can be found here.

Many many thanks to @haarg and @oiami for implementing the actual feature, and to all participants of the corresponding ticket.

More questions? Chat with us :)

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.