Lets play Lacuna Expanse

While normally I never play Facebook'y web games like Farmville, clearly an exception should be made for Lacuna Expanse, especially since it's made with Perl and since it's only been running for 2 days, we can set up a nice little Perl posse in the very first week and rule the universe!

(Evil laugh follows, echoing and trailing into the distance)

(I am contactable with the rather unimaginative empire name of "Adam")

This game probably also marks the highest volume and potentially most high profile user of Email::Stuff (one of my favourite little creations) outside of myself and Ricardo who now maintains it.

http://www.lacunaexpanse.com/

As a small bonus, the game seems to be the Farmville equivalent of EVE Online, which is at least a familiar genre for me :)

Learning Perl sells decently well, even in eBook formats

It's royalty report time, so the mailbox was full of checks this week. I keep close tabs on how well my books do so I can figure out if the time to write the books would have been better spent making fancy coffees at Starbucks. I think I'm slightly ahead, but only slightly.

However, I noticed that the total revenue for Learning Perl, 4th Edition is very close to $1,000,000 for the 20 quarters it has been available. And, curiously, it's getting closer to that number even though the latest edition has been out for 9 quarters. Who's still buying the old edition?

Even better, though, the Fifth Edition is already over $500,000 in total revenue. Now, only a small slice of that gets to the authors, especially on a title with multiple authors, and that only comes four times a year over several years. My cut of Learning Perl, 4th Edition is only 1%, so I'm not buying any Bentleys.

Sometimes you *don't* want circular checking

I use the nifty Data::Rmap to "flatten" DateTime objects into strings so they can be exported to JSON and handled outside Perl. But due to circular checking in Data::Rmap, this:

$ perl -MData::Rmap=:all -MData::Dump \
-e'$d = DateTime->now; $doc = [$d, $d];
rmap_ref { $_ = $_->ymd if UNIVERSAL::isa($_, "DateTime") } $doc;
dd $doc'

produces something like this:

["2010-10-01", ...unconverted DateTime object...]

For now I work around this by defeating Data::Rmap's circular checking, though I wonder if there's a better way.

$ perl -MData::Rmap=:all -MData::Dump \
-e'$d = DateTime->now; $doc = [$d, $d];
rmap_ref { $_[0]{seen} = {}; $_ = $_->ymd if UNIVERSAL::isa($_, "DateTime") } $doc;
dd $doc'

will correctly produce:

["2010-10-01", "2010-10-01"]

Mangling CPAN with Plack::App::Proxy

If you want syntax highlighting when viewing docs and source at search.cpan.org, you don't actually need to use Greasemonkey. You can do it with Plack and be up and running in just a few minutes.

Last night I gave a lightning talk about this at Toronto.pm and I've just posted the slides

Basically, all you need to do is this:

---
git clone http://github.com/ioncache/Plack-Middleware-HTMLify.git
git clone http://github.com/oalders/cpan-mangler.git

cpanm Plack Plack::App::Proxy Plack::Handler::Twiggy

cd cpan-mangler
plackup -I../Plack-Middleware-HTMLify/lib
---

Once you've got that done, just point your browser at http://localhost:5000 and use search.cpan.org as you normally would. It's the same site, only prettier. Now, it's not perfect, but it's a fun idea. Using the proxy setup you can bend the site to your will and add or remove features as you see fit.

cpan-pod-after.png

cpan-source-after.png

What's in a name?

For my recent projects, I've been using Dist::Zilla and enjoying its very advanced features. The reason I've never used it before? I thought it had a silly name. I still do, in fact, just that I managed to ignore the silliness enough to find out it incorporates some major wins.

Another project I overlooked is KiokuDB. I was looking around for a non-relational/Object-based/Document-based Database (aka NoSQL), and kept overlooking KiokuDB for two reasons; first, KiokuDB is a front-end to several different back-ends, including RDBMS like MySQL and Postgresql, making me unsure whether it is a true object-based DB, or just a glorified ORM, and second, it has a silly name.

I solve another big set of problems for MyCPAN

I knocked off another big chunks of distributions that MyCPAN didn't like. I worked on the 700 or so dists that it couldn't unpack, and that number is now down to about 30. The changes to my method weren't that dramatic, but it clears up a bunch of the problem dists.

First, I was stopping too soon. Many archives unpack just fine even if they give warnings. Now I'll just record the warnings and wait to see if I get a directory with some files in it.

Second, I was using an HFS case-insensitive file system (stupid, but it's the default). Many distributions did not like that. Moving everything to a case-sensitive file system solved many of those problems. Once I find out why Foo-Bar-0.01.tar.gz doesn't unpack, I usually solve the problem for all Foo-Bar-* series which probably had the same problem.

Littlest uuencode

Hi, For your amusement, here's a very small uuencode program.

perl -0777 -e '$uue = pack u, <>; print "begin 0644 $ARGV\n${uue}end\n"' your-file.bin

Perl-based Massively Multiplayer Online Game

JT Smith and his crew have created a massively multiplayer online game called the Lacuna Expanse. The game is great, but the coolest part is that the back-end is written entirely with Perl!

JT unveiled the game and the underlying technology at the latest Madison Perl Mongers meeting.

Amsterdam

I've mentioned this elsewhere, but I thought it was worth mentioning here: my wife and I are moving to Amsterdam next month. After three lovely years with the BBC, I'm giving in to the temptations of Amsterdam and booking.com. Here comes a new adventure!

A `tail -f` in BBEdit.

I knew BBEdit would update open files when they changed on disk, but I never thought to try that with a continually updating file. It works. You just have to have the file open. No big whoop.


Yet another stupid mistake #1

During a refactor of a data from array @foo to hash %foo, I used 'each' to iterate over the hash, but forgot to change the 'for' statement with 'while'. So I ended up with something like:

$ perl -MData::Dump -E'%a=(a=>1, b=>2);
for (my ($k, $v) = each %a) { $_ = "$k x"; dd {k=>$k, v=>$v, "\$_"=>$_} }'

And this is nasty because for(@ary) aliases $_ to each element in @ary, and in this case it modifies $k (quiz #1: and $v too, do you know why?) right under your nose! Thus the result are really messed up:

{ "\$_" => "a x", "k" => "a x", "v" => 1 }
{ "\$_" => "a x x", "k" => "a x", "v" => "a x x" }

Not to mention the loop stops after processing two items (quiz #2: do you know why?) But you might not realize that after you add some pairs to %a and wondering why they don't get processed.

The error message Perl gives is not really helpful, to say the least :)

Hackathon


We'll have another hack session at Quetzal Internet Cafe in the
middle of October. The location is close to Civic Center BART,
and the 38, 47, and 49 bus lines. Come bring you laptop and hack on your
favorite CPAN module, and chat with fellow SF.pm Perl Mongers.

Announcement posted via App::PM::Announce

RSVP at Meetup - http://www.meetup.com/San-Francisco-Perl-Mongers/calendar/14948010/

One-liner XML / Perl / JSON

castaway blew my mind this morning in irc.perl.org #axkit-dahut.

Convert an XML file to Perl data structure:

perl -MXML::Simple -MData::Dumper -le'print Dumper XMLin("foo.xml")'

Convert an XML file to JSON:

perl -MJSON::Any -MXML::Simple \
   -le'print JSON::Any->new()->objToJson(XMLin("foo.xml"))'

"How do I do X?" Like this! Poof!

Some days Perl feels like a Las Vegas magic show. :)

Reading META.yml when it's not UTF-8

Part of the 3% of the distributions I couldn't index with MyCPAN had encoding issues. YAML is supposed to be UTF-8, but when I don't always get UTF-8 when I generate a META.yml for files that don't have one. I guess I could do the work to poke around in Makemaker, etc, to convert all the values before I generate the META.yml, but um, no. Not only that, not all of the META.yml files already in the dists are UTF-8. Remember, however, this is a very small part of BackPAN: about 700 distributions out of 140,000 (or about 1/7th of my problem cases).

A couple hundred distros have Makefile.PL files encoded as Latin-1 in a way that it matters. If it's not collapsable to ASCII, the META.yml ends up with Latin-1 in it. Some YAML parsers refuse to deal with that.

blog moving

Moving my blog here from blog on use.perl.org

I couldn't help it - Parsing Empathy log files in 20 seconds or less.

My current instant messaging application is Empathy. It's nice, though I wish it had a Perl interface, plugins and a few more features I want/need. It never matters enough to actually change applications.

Today I needed to go over a history file with a colleague that was pretty long. Popped up the "previous conversations" in Empathy to find that the record starts from the last hour or so (out of about 5 hours long of history). How nice.

I searched for the actual log files and found them in ~/.local/share/Empathy/logs/gabble_jabber_user_40domain_2eextension0/colleague@domain.extension. Comfortably they are in XML form. Excellent!

I shouldn't be parsing XML (or any other SGML) with regular expression. I know that! But.. I really really wanted to have it in 2 seconds instead of 2 hours, I could help it!

I reckon if it's specific enough and won't be used for more than this specific minute, the standards police (which I love and cherish) will let me off the hook this time.

Using blogs.perl.org

I stumbled into blogs.perl.org last night. Here's a couple "quick start" tips for using this install of Movable Type Pro:

(1) Code blocks. If you choose Format: Markdown, leave a blank line, indent text with 4 spaces, then another blank line

you will get code blocks like this
# with some
$rudimentary = "syntax highlighting";

(2) Blog subtitle. Erez Schatz was kind enough to point out how to set your blog subtitle (e.g.: Mutation Grid, Inc. "Controlled software evolution." above): From the blogs.perl.org page, click on Post, then, on the top menu bar: Preferences - General, the subtitle is "description".

Writing Plack Debugging Middleware for Catalyst

I now have our work project running (sort of) on Catalyst 5.80007. This is because it's the oldest version of Catalyst I can use with Plack. I wanted that just because the debugging middleware for Plack is just so friggin' awesome and I wanted to write my own. Now I have and here's how easy it is (with screenshots).

September Meeting of Erlangen.pm

This months meeting took place in the refurbished Trattoria Dolomiti.

We were eight perl mongers and had a special guest, Bernd Hendl. Bernd guest had nothing to do with actual Perl programming but he was searching for a new employer for some Perl web applications of his company.

Topics that came up this past meeting were:

  • Version control systems; ranting about commercial VCS'
  • Company policies regarding development tools
  • Local Perl job market (spawned by Bernd's job offer)
  • mod_python, and a weird bug that one of the mongers observed therein on a production machine
  • higher order functions (like map and grep), their (non-)existance in various programming languages, and if higher abstractions make code harder to read or not

Note that often we don't settle on any topics in advance, but just let the discussion flow.

If you are in the Erlangen/Nuernberg area, don't hesitate to visit our monthly meetings, or contact us for extra meetings if your visit don't coincide with the third Monday of the month.

So who knew...

I'm currently working with extracting data from a system with an XML based command UI, so I am fairly often dumping serialised (using Data::Dump) perl objects out whilst debugging.
To make the piles of debug output easier for me to parse I pushed the files through Perl::Tidy.
You would not believe how long it takes, or how much memory is required, to run 110MB of perl datastructure dumps through perltidy!
Actually I don't know how long or how much memory it took either - I killed it after half an hour and 3GB.
I mean, who knew! :-)

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.