2022-04-10 How to Perl

Eating breakfast, alone. My wife is taking a very long shower and we have to leave, soon. Must have breakfast before we leave! Also, I forgot to put salt in this bread. Everything is strange.

I recently worked on the Character Sheet Generator for Halberds and Helmets. I think most of that development happened back in 2015. I still use it, mostly to automatically generate a bunch of first level characters. The Monday Characters where generated like that. My idea was this: even if character generation is fast, it’s still not fast enough if we have less than two hours per session so people should just pick a character from the list. In order to ensure that the characters with below average stats are also picked, and to avoid the “click character generator link until you like the result” inclination, the setup was going to be as follows: I’d generate twenty characters and I’d only generate twenty more when all of the initial cohort had been picked by players. Since I’ve since been a player in the Barrowmaze dungeon, I’ve had to do just that and I’m happy with my hapless mages.

Character Sheet Generator

Halberds and Helmets

Monday Characters

I don’t know anybody who uses the character generator. I guess @funkaoshi’s Basic D&D character generator sees a lot more use. It looks nicer, for one! So yeah, I know it’s just me. But still: my web apps can be hard to install and I figured that if only I had them set up such that I can upload them to the Comprehensive Perl Archive Network (CPAN), the code and its declared dependencies would automatically have to be good enough to pass the tests and that in turn would improve the code quality, the documentation, the installation, and also make sure it survives me in some form.

@funkaoshi

Basic D&D character generator

So that’s what I’m doing.

Once installing via CPAN is possible, there’s also the option of providing a Dockerfile that interested parties can use to generate images. I don’t need to generate the images for every commit. No need to waste all that CO₂! But it’s nice to see that it works. Basically the Dockerfile acts as documentation for people wanting to know how to install it all, and it makes sure that the git repositories come with sane default config files and all of that. I like the effect this is having on my code!

If you’re interested in hacking on some Perl code, however, how would you get started?

The first question is going to be this: are you going to use only packages for your system, or will you start downloading code from CPAN? I usually run into problems eventually when I realise that some Perl module is not packaged. To stick with the Character Sheet Generator, here are the declared dependencies from the “Makefile.PL”, and the respective Debian packages that provide them. You can find them all by using “apt search …”.

As you can see, there is a naming convention at work.

If you want to do development independently of your system’s Perl, you need a different solution. Over the years there are always moments where this is required. If your development machine and your server don’t upgrade at the same time, for example. So what do you do?

The first step is to install Perl using Perlbrew. The Debian package is called “perlbrew”. You install Perlbrew, and with it, you install Perl into your home directory. The website has more info; or you can run “perlbrew help”.

Perlbrew

You probably want the following to setup your shell init scripts and to install the latest stable version:

perlbrew init
perlbrew install stable

See which version you now have available:

perlbrew available

Switch to it, replacing XXX with the version you have available:

perlbrew switch XXX

You might have to start a new shell for the changes to take effect.

This installation then has it’s own library directory and thus you need to install all your libraries there. My preferred tool to do this is “cpanm” (i.e. not the old “cpan”). Happily, Perlbrew comes with a command to install it:

perlbrew install-cpanm

Now you can install modules as follows:

cpanm Game::CharacterSheetGenerator

​#Character Sheet Generator ​#Halberds and Helmets ​#RPG ​#Perl