Kiss Kiss Shebang Shebang

At the end of the discussion, our sysadmin commented:

Perl sure does seem to need a lot of scaffolding these days before one can get around to the business purpose.


And my response was that Perl had always needed a lot of scaffolding.  It’s just that we never used to notice, because it was all built-in.

Pretty much every Perl tutorial is going to tell you that the first line of your first Perl script should look something like this:

#! /usr/bin/perl

More details on the CPAN Pull Request Challenge

The CPAN Pull Request challenge has had way more signups than I was expecting: 343 so far! Some are very experienced Perl programmers and CPAN contributors; some are long-term Perl programmers using this as a way to "give back"; a few are new to everything.

I wouldn't have predicted 300 pull requests in the entire year. Now we might get that in January alone! I know some people are concerned of the effect that this wave of locusts enthusiastic contributors might have, particularly if authors have to start dealing with pull requests that don't really add much value.

As a result I think it's probably helpful to give some more details on the challenge, give CPAN authors a chance to comment, and even to opt out.

Can you provide an x/y Point class in other languages?

Update: Thanks for all of the replies. However, I now need to block further replies due to the huge amount of spam this post is getting.

I'm writing a talk for Fosdem entitled "Perl 6 -- A Dynamic Language for Mere Mortals." The talk is about Perl 6 and is aimed at programmers, not just Perl devs. As a result, I'd love to find examples in Java, Python, Ruby, and so on, which are roughly equivalent to the following Perl 6 class.

class Point {
  subset PointLimit of Real where -10 <= * <= 10;
  has PointLimit $.x is rw = 0;
  has PointLimit $.y is rw = 0;
  method Str { "[$.x,$.y]" }
}

That class lets you do something like this:

my $point = Point.new( x => 5, y => 3.0 );
say "$point";                             # [5,3]
$point.y = 17.3;                          # Boom!

In other words, both X and Y are real numbers constrained between -10 and 10, inclusive, and overloads stringification. What follows are two roughly equivalent implementations in Perl 5.

Serializers for Perl: when to use what

This is a moderately edited (primarily rearranged) version of a comment on the Perl 5 issue tracker written by Yves Orton (demerphq). I thought it would be useful to a wider audience so I am reposting here with permission.

Note: this was written off the cuff and is not comprehensive. In correspondence, Yves noted that such an article could/should cover more formats, e.g. MsgPack.


I [feel strongly] that Data::Dumper is generally unsuitable as a serialization tool. The reasons are as follows:

A little warning to EUMM and shell-script users

I sometimes need to write shell-script test scripts and not perl, to be able to test perl scripts, without interfering with perl, and also for performance and easier IO reasons.

In order to find out with which perl this distro was built, we need to parse the generated Makefile.

Recent EUMM 7.0x introduced a new feature which broke all my scripts. They started double-quoting PERL and FULLPERL in the generated Makefile. Damage is already done. They only thing you can do is to remove the quote.

PERL=`grep "^PERL =" Makefile|cut -c8-`
PERL=${PERL:-perl}
PERL=`echo $PERL|sed -e's,^",,; s,"$,,'`

They obviously were afraid of spaces in Windows paths. Only cmd.exe accepts "cmd", no other shell. So the obvious fix would be to add double quotes on Win32 only, and only of a space appears on the NAME or the PATH. Same as we have to do with $^X in system calls, where we have to double-quote $^X explicitly in string -context. Like with

The sad story of pseudohash criticism

I just had to endure MJD’s horrible pseudohash explanation at the Pittsburgh Workshop. “A new, never-before-seen talk on Perl’s catastrophic experiment with “pseudohashes”, which wasted everyone’s time for nine years between 1998 and 2007”

https://www.youtube.com/watch?v=-HlGQtAuZuY

Watch it, you can fast forward through it. I honestly had higher opinions on Marc-Jason.

So let’s see what’s wrong with the popular and uninformed pseudohash critic:

Their main points are that storing a hash in the array slot 0 for run-time lookup is too complicated, the exists and delete ops need to check for arrays / pseudohashes now also, and all the pseudohash checks slowed down general hash usage by 15%. Which basically levelled the advantage of faster compile-time accelerated array lookup on those pseudo hashes, which was ~15%.

package Critter;
use fields qw(NAME TYPE);

my Critter $h;    # compile-time optimization: href NAME => aref 1
$h->{NAME};     # ==> $h->[1]

but:

$key = "NAME";  # defer to run-time lookup of href in aref 0
$h->{$key};       # ==> $h->[ $h->[0]->{$key} ]

CPAN Pull Request Challenge: The Pull Request

In my last report, I had received an ok from the module's author to proceed with a pull request. The first thing I did, as I had with the modules referenced by Devel::StackTrace::WithLexicals, is to write an example for myself so I could see how it worked. Working from the synopsis, I had a difficult time writing a working piece of code. It occurred to me that this was the very place I could start with a Pull Request.

More

MetaCPAN Welcomes Panopta as a Sponsor

As you may know MetaCPAN as a project has no budget. We rarely solicit funds because we rarely need to pay for anything. This has allowed us to focus on the project itself rather than the administrative issues that arise whenever money changes hands. Because these relationships allow us the freedom to do what we need to do, we think it's important to thank our sponsors publicly.

And with that introduction I'd like to thank Panopta, the latest sponsor in the MetaCPAN world.

A while back I put out a call on Twitter to see about getting someone to sponsor a monitoring solution. Less than 30 minutes later, I got a response directly from Panopta. I started an email conversation and we had a sponsored account in no time.

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.