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.
Now to make some sort of fixture loader. Hmmm... what should it be call?
Very cool! I can think of some good uses for this.