2024 Advent Of Code in Perl
The title says it all. I've never programmed in Perl. I hacked some existing scripts, but never tried this oldie. But as it is a great language for text processing, it was time to start learning it. Maybe it will come handy some time in the future.
My repo is at https://github.com/sixhat/adventofcode.com/tree/main/2024/
Notes on using Perl for AoC
(or... things I'm learning along the way)
unless
is interesting, but I have to get my head around it. But it works.- $@% ? What? I have a lot to learn on the syntax front of Perl.
use strict;
anduse warnings;
are your friend- Pass by value and pass by reference are dependent on a lexical variable being created on the subroutine
my @local_var = @_
. - Regular Expressions are powerful, but they also introduce some complexity and trying to debug them is harder.
Use of uninitialized value
warnings reveals someundef
entries in an array (for example in my@matches
). Trick to check them out is toprint join(', ', @matches)
to double check.- smartmatch is really nice (day 5).
- Install a repl - Reply - or any other. It makes testing simple things in the language a breeze.