Introducing Begin::Declare

While working on a module for source code injection, one of my example "macros" was one that allows you to declare and assign to a lexical variable at compile time, without having to write the variable names twice. That concept more or less hijacked the conversation, and after some prodding from p5p to make the interface better, I've used Devel::Declare to add two new keywords to Perl, MY and OUR.

Here is the synopsis from the module:

don't you hate writing:
my ($foo, @bar);
BEGIN {
    ($foo, @bar) = ('fooval', 1 .. 10);
}
when you should be able to write:
MY ($foo, @bar) = ('fooval', 1 .. 10);
just use Begin::Declare; and you can.

The module lifts the computation of the rhs to compile time, as well as the assignment.

https://metacpan.org/module/Begin::Declare

Unicode rant

People these days are saying that you should always decode your utf8 strings, enable utf8 binmode, etc.
This is not true.

I live in Russia, so half of strings I deal with contain cyrillic.
99% of the time they are not decoded.
And you know what, it's fine.

Here is the problem with decoded strings:

$ perl -MEncode -E 'my $a = "абв"; my $b = "где"; say $a.decode_utf8($b)'
абвгде

If you concatenate two strings, either both of them must be decoded, or neither of them.
You can't mix two styles.

So there is no way to migrate gradually to unicode in existing project if it's large enough.

But 99% of the time you don't need decoded strings at all.
And when you actually need them, simple wrappers are enough:

sub lc_utf8 {
my $x = shift;
$x = decode_utf8($x, 1);
$x = lc($x);
$x = encode_utf8($x);
return $x;
}

Perl Accepted For GCI - Now We Just Need Students

Some of you may remember that a couple of weeks ago I wrote about how The Perl Foundation was hoping to take part in the Google Code-in 2011 (GCI) and I badgered you for help in providing tasks and acting as mentors in the programme.

I am happy to announce that the application of The Perl Foundation has been officially accepted and Perl will be taking part in GCI 2011. This is due in large measure to the wonderful reaction to our appeals which has lead to numerous high quality tasks being added to the ideas page and many selfless developers volunteering to be mentors. Without your assistance our application would not have been successful, so thank you very much to everyone involved.

But the tasks are only part of the story. Undoubtedly the track record that Perl has in GSOC as well as last year's GCI was a contributing factor, as was the leadership of Florian Ragwitz and Mark Keating. So many thanks to everyone who has brought us to this point.

Are You Thankful For YAPC?

With the American holiday of Thanksgiving right around the corner, perhaps it's time to consider what you are thankful for, and hopefully one of those things is YAPC. If so, you can show your thankfulness by marking down on the paper or digital calendar of your choice that you're coming to YAPC::NA 2012 on June 13-15 in Madison, WI. And if you're not sure you can afford it, ask for it as a Christmas present!

Also don't forget that you can bring your spouse or significant other with you to enjoy our Spouses Program

The End Of 5.6 Is Nigh!

It's that time again! Time when I hammer the last few nails in the coffin of a version of Perl. A few years back, I killed 5.004 and 5.005 in a stroke by uping the minimum version of Test::More, upon which 80% of CPAN relies, from 5.004 to 5.6.0. In a few months I'll be doing it again.

Act Workshop

Rob Hoelz, the leader of our software team for YAPC::NA 2012, is holding an Act workshop from 5pm to 7pm at the Essen Haus on Tuesday, November 15th. These are the two hours before our normal MadMongers meet up. Don't worry if you can't make it for the entire two hours. People are free to come and go as they please. But if you want to learn about how you can help enhance Act for YAPC, then you should definitely try to make it. 

Bring a laptop with you, preferably with Perl already installed. If you don't have a laptop, then we can buddy you up with someone that does. Rob will take care of the rest once you arrive. Hope to see you there.

Graphing time-based data in Perl

Just posted about Graphing time-based data in Perl on my blog, documenting my decisions in picking a suitable module to easily graph potentially irregularly-spaced time-based data in Perl.

Chart::Strip turned out to be what I wanted. See the full post for what lead me to choose Chart::Strip, and sample usage & output.

BPO Meta : UserPics, API Passwords & Site Build notes

It's been reported that blogs.perl.org UserPics are broken. I don't agree.

First login to blogs.perl.org

Then click the link to your user preferences. (Click the images to get the fullsized versions that aren't "squished")

(update: an existing issue that isn't fixed is that some markup in the body of a post will show up incorrectly on the homepage because MT is truncating the post for the homepage, and clips the post badly half way through, leaving gargbage on the homepage .. hence this paragraph which pushed the next bit of HTML off what is shown on the homepage ... patches welcome .. see below)

1.png

Then upload a picture. Note a little further down you can also get the password required for the API / Web Services, which is another reported issue.

2.png

Then return to your blogs admin page:

3.png

And then republish your blog:

4.png

And that should then show your UserPic on your blog posts/profile. You may need to refresh/reload your browser to cache-bust.

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.