Announcing Test::mongod

After having done a couple of projects with MongoDB and working on and off on a personal project, I found myself wanting something like Test::mysqld, but alas it did not exist on CPAN. So here it is Test::mongod. It's rough but will get you a throw away instance of MongoDB in a /tmp directory that will be cleaned up when the script ends. The code can also be found on GitHub.

use Test::mongod;

then....

my $mongod = Test::mongod->new;  # get a temp db on a random port.
my $port = $mongod->port; # get the port to feed to your client app.

Be aware that depending on your hardware, this will block till the server is listening and ready to receive queries - which could be instant or take several seconds. To monitor startup get the db path and then tail the log file in another terminal.

diag $mongo->dbpath

Now to make some sort of fixture loader. Hmmm... what should it be call?

Tie::File don't while(<>)

Consider the common case where you want to take a text file and walk it doing various operations such as stripping whitespace, looking for duplicates, sorting or other common operations. I was recently asked to work on a program where part of the process is 'cleaning' uploaded files before doing other things with it. This process was over 40 lines of subs opening old and new filehandles, doing the standard while(<>) {} and then renaming new file to old file. If you find yourself wanting to do something you would normally do on an array, but on a file and often in place, consider Tie::File before while()ing away at it. The documentation has many examples and there are several examples on the web including at Perl Monks. In this case I was able to whittle this down to this:

tie my @file, 'Tie::File', $file;
@file = grep !$seen{$_}++,
            sort,
            map s/$RE{ws}{crop}//g,
            map lc, @file;

untie @file;

If you're working with CSV or other delimited files, consider Tie::Array::CSV

Cheers

Announce Classmith.com

Ok, I took up JT's challenge to build something. Here is the MVP launch of classmith.com it only works on https right now so don't try 80. Mojolicious, DBIx Class (Candy) and a healthy dose of DateTime::Set and a couple of other DT modules with Bootstrap frontend. This app is meant to be a tool for the growing group of tech savvy, [home|un|hack] schooling crowd, with features for those that are location independent. I already have a roadmap of about 30 items to add and to start work on the mobile syncable version. All feedback is welcome. Thanks.

Perl Success Story - Managing PHP apps with Perl

WebPub helps install and manage popular web apps. We currently are doing WordPress, Drupal, MODX and phpBB. While the web UI is in PHP (decided before I came onboard) the backend is all Perl.

Some of the major components being used are: Mojolicious, Moose, DBIx::Class and Gearman.
Mojolicious provides the REST interface for the PHP front end and will be used in the near future by at least one other company we are working with. That company will write their client in Ruby.
Moose is used heavily for meta method creation, mapping various before / after 'method' to validation and DB update_or_create and the installer system loads the appropriate role (each app has its own role for things that are app specific - an install of Drupal needs more fixup than WP) at runtime.
DBIx::Class - no explaination needed
Gearman - actual interaction with remote systems happens from workers.

YAPC::NA 2012 donate ticket

I will not be using my badge to the conference. Is there a place where I can put this in a 'needs' pot? To be used by someone who can make the conference, thanks.