Perl Adventures
Over the past few years, I've decided to finally practice programming in perl.
First, I had an idea for a little goof that I was curious about when I noticed that the wordle score with the 5x5 boxes sort of looked like gliders from the game/programming exercise, Conway's Life.
So I learned enough perl to make a CGI script that I figured that I could put on SDF. I learned some more modern CGI with templates and that was data safe. But it turns out, because SDF had switched to nginx as a web browser, that it was much more complicated than making a old-style CGI. Mojolicous and plack didn't work, because they depend on app servers sitting behind the webserver, AND it turns out that nginx at SDF was not set up to pass path_info to CGI. SO nothing I wanted to do worked.
I had to figure out a thing that did work, which was a module called "CGI::Tiny", which ended up working, and I figured a way to mock up my own path_info in my script. So that is how the Wordle-Life project was born, at https://git.sdf.org/peteyboy/wordle-life.cgi
Later, I rewrote it a bit using Mojolicious and set it up to run on a VPS on a perl mojolicious server. It was a funner exercise, to be honest, and cool to run my own custom web server.
THEN, more recently, I had a different idea. Someone posted a Mastodon toot someone made about a website called nightfall.city, sort of a smolnet thing, with its own simple nc/TCP based "protocol", Nightfall Express, or NEX (nex://)
I sat down and put together my own client, using perl, and using the telnet and Curses modules, so I could make a terminal based, yet windowed app. It was way more work than I thought, and I got a little obsessed with it, but I did get it done, and it's honestly kind of cool.
Dumb Packaging Lessons
I tried to package my nightfall.city NEX protocol browser. It's just a script, but it does have dependencies, and if I want someone else to use it, their perl environment needs to be set up, and you can't have it so complicated as loading each module with cpanm. I figured I needed to make a distribution package to load these items.
I ended up trying to use Module::Build::Tiny via App::ModuleBuildTiny
Turns out there are tricks
- You have to make a "fake/empty" perl module a file, lib/App/Connex.pm, that has the package App::Connex, and has perl "use" commands for each module you are using in your script
- You have to use the "mbtiny dist" to build a gzip distribution
- In order for it to run, it will tell you there is no "Changes" file, which is a file the app won't build
- You have to make the Changes file in particular format or it will be ignored
- Even when you do the build process
- mbtiny listdeps | cpanm
- mbtiny test --release
- mytiny regenerate
- Don't do: mbtiny upload, but mbtiny dist, instead
- It *still* won't automatically load the modules. After going through a complicated build process, it just provides you a list of required modules in a file called "MYMETA.json", which, if the installer has 'cpanm' installed they can use to load all required modules with "~/perl5/bin/cpanm --installdeps . "
- Then the installer can throw away all the other files except the one script file *whew*