File::Slurp is broken and wrong

If you are using File::Slurp, you should possibly reconsider. Basically, there are three reasons to do so;

It is wrong in a lot of cases.

File::Slurp predates IO layers, and as such doesn't take them into account well. A few years ago, after some complaints, an attempt was done to make it handle encodings. This was nothing short of being wrong.

The best known bug in this area is #83126, which means that :encoding() layers are always interpreted as :utf8. This not only means that UTF-8 encoded text is not validated (which can be a security risk), but also that files in other encodings (such as UTF-16) will be read as UTF-8, which surely will give an incorrect result.

Likewise it's not handling :crlf correctly, in particular explicitly asking for :crlf will always disable it, even on Windows.

Basically, it's doing all binmodes wrong except the one you shouldn't be using anyway (:utf8), and you should pretty much always be using a binmode, so there's no way to win really.

Last Minute Hotel Rooms @ Swiss Perl Workshop

The organisers of the Swiss Perl Workshop would like to inform you that they are freeing some hotel rooms by tomorrow, Wednesday 19 August, 18 CET.
The rooms are in the hotels Amaris and Oltnerhof, both within 5 minutes on foot from the venue.
Reservations were made for the duration of the workshop, Perl 6 hackathon included (Wednesday 26 August - Sunday 30 August)

Perlito - reviewing some older code

Today I've finally updated the Perlito compiler ChangeLog, this covers a little more than a year of commits.

The most significant update was the new Perlito5-to-Java backend, which is work-in-progress. It covers a lot of ground, but there is a lot more.

There were also some interesting new Perlito5-to-Javascript features, such as regex /e modifier, and file operators support in nodejs.

The Perl6 backends have not been updated, but things still work.

While reviewing the README-perlito6 file, I've found some interesting stuff that I haven't touched in a while - here is a piece of generated code that goes through 3 different languages:

CPAN is 20!

Perl hackers have now, as of today the 16th August 2015, been uploading Perl modules onto CPAN via PAUSE for 20 years. Andreas König, who did that first upload, is still releasing to CPAN, and as I write this his most recent upload is the same module that was first released to CPAN.

This post is a brief summary of CPAN's history.

Happy CPAN Day!

Can you believe CPAN has been around for 20 years today? Two decades is a long time! Yet, I cannot imagine my workday without it.

My contributions to the CPAN Day celebration:

Helios 2.83 is a minor release of the Helios distributed job processing framework. It contains official SQLite support for the first time, better schema DDL for Oracle databases, and some cleanup of some files with mixed-format line endings.

Helios::Logger::HiRes 1.00 is the first stable release of a plugin module
providing enhanced logging features to the Helios framework, including
sub-second timestamp precision (provided by Perl's Time::HiRes) and a
command line log searching tool.

Thank you to everyone who contributes to CPAN, both package contributors and those that maintain CPAN itself. Happy CPAN Day everyone!

The newly-released Regexp::Assemble V 0.36

I'm now co-maint of Regexp::Assemble. V 0.36 has been uploaded to CPAN.

Perl開発の助成金プログラムについて

This is a Japanese summary of Grants Committee Charter, How to write a proposal and Grant Benefits.

YAPC::Asiaが目の前に迫ってきました。日本のPerl使いの皆様向けにThe Perl Foundation内のGrants Committeeの活動を紹介します。

以前Grants Committee委員の牧から案内がありましたように、Grants CommitteeはPerlの開発に貢献する個人に1万ドルを上限として助成金の交付を行っています。もちろん日本の皆さんも対象で、最近はmoznion氏のPerl::Lintが採択されました。以下に私たちの活動理念と助成金の応募方法を記します。少し長いですがどうぞお付き合いを。

Grants Committeeの紹介

Grants Committeeは米国非営利法人、Perl Foundation内の最大勢力を占める委員会です。

Grantは日本語に翻訳しにくいのですが、助成金委員会とでも申しましょうか。オープンソースの活動は個人が自分の時間を使って無報酬で行われることが多いものの、人間は霞を食べて生きるわけにはいかないため、Perlのプロジェクトを通してPerlの成長に貢献してくださる方にGrants Committeeが助成金を出しています。

委員長は私、野崎が務めています。委員はコミュニティの代表を世界各地から集める方針を取っており、アジア・太平洋地域からは牧大輔とKaren Pauleyが選出されています。その他北米4人、欧州の4人の委員に加え、アジア・北米・欧州からGrant Managerという役職に1名ずつついており計14人の所帯です。

助成金の申請から採択、支払いまで

流れはこのようになっています。

  • 提案の送付(フォーム)。このようなプロジェクトををするのでこれだけの助成をされたい、という内容を送っていただきます。メールアドレスなど個人情報を除き、内容は公開されます。
  • 奇数月の中旬にパブリックコメントを募集し、委員による投票が行われます。
  • 賛成多数で採択。提案に沿って実行していただきます。なお月一度の進捗報告が求められます。
  • 計画達成後、現金が支払われます。

参加する利点

採択されると助成金に加えてこのような利点があります。

  • 専属マネージャーが割り当てられ、進捗管理とTPF間の仲介をしてくれます。
  • TPFお墨付きのプロジェクトになり、世界中から注目が得られます。

FAQ的なもの

英語は必要か?

英作文が必要になるのは以下の場合です。

  • 提案の作成、質問への返答
  • 進捗報告
  • 支払い手続きなど事務的なやりとり

READMEを書く手間プラスαくらいでしょうか。牧によると「英語が問題ならば多少のお手伝いはできます」そうですよ!

申請額はどうやって決めたらよい?

上限が1万米ドルという以外、特にガイドラインは設けていません。過去の申請額を参考にするのがよいかと思います。なお2014年2月までは上限が3000ドルでした。

寄付金で成り立っているプログラムのため、時給換算ではさほど多くの額は望んでいただけないことをご承知ください。

支払いは?

計画達成後、委員会が確認したあとに米ドル建ての小切手が郵送されます。小切手はシティバンク銀行などで換金できます。銀行振り込みもできないことはないのですが、国際送金手数料の負担をお願いしています。

ちなみに円安の今がチャンスです。

財源は?

TPFに寄付をしてくださった皆様のおかげです。末筆ながらTPFに寄付をしてくださった法人・個人の皆様に感謝いたします。

お問い合わせ

tpf-grants-secretary at perl-foundation.orgへどうぞ。

Converting glob patterns to regular expressions

Let's say you have a glob pattern with shell-style wildcards from a config file or user input, where ? matches any character and * matches any string (0 or more characters). You want to convert it to a regex, maybe because you just want to match it (and Perl already supports regexes) or because you want to embed it as part of a bigger regex.

You might start with a naive replacement:

s/\?/./g;   # ? -> .
s/\*/.*/g;  # * -> .*

Unfortunately this is broken: It leaves all other characters untouched, including those that have a special meaning in regexes, such as (, +, |, etc.

Let's revise it:

s{(\W)}{
    $1 eq '?' ? '.' :
    $1 eq '*' ? '.*' :
    '\\' . $1
}eg;

Now we match and replace every non-word character. If it's ? or *, we turn it into its regex equivalent; otherwise we backslash-escape it just like quotemeta would do.

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 hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.