So I'm trying to copy a list-of-lists, then do something with the new list. Bear in mind that I'm reasonably new to working with LoLs and thus don't know why, once I have finished adding columns to the second one, the columns are also present in the first. That's becausee I was using
@NewLoL = @LoL; #add some columns to @NewLoL, actual code is #incidental but it was to compute the full 4x44 key block #for the AES. #getdim is a routine to return the number of rows and #columns in a LoL ($row, $col) = getdim(@LoL); print "$col";
$col was turning out to be 44, when to my eyes it should have been 4. Wrong. After the first line, both @lol and @NewLoL were lists containing references to the anonymous lists that was the rows. As I was adding to those rows when I manipulated @NewLoL, the arrays were growing, and thus when I used @LoL, these were the same arrays referred to in @NewLoL.
Only once I had implemented a very fast deep copy which would get the first 4x4 of @NewLoL did the program work, and it took half an hour afterwards of hard thinking for me to finally grok why I had needed to perform a deep copy.
Yeah, I'm an idiot. But I'll never make that mistake again.
Now, I relax for some and star working on decryption. Of course, I need to find the inverse Sbox as it's not provided anywhere in the book and I'm fucked if I'm doing yet more matrix multiplication in GF(2^8). But this should now be easy.