1
perl 5.44 (linuxiac.com)
submitted 2 days ago by to c/perl@programming.dev
 
 

Perl 5.44 has been released, bringing several experimental and compatibility changes:

  • Named parameters in subroutine signatures (e.g., sub foo ($name, :$email)) are now supported, allowing callers to pass arguments as name‑value pairs.
  • Combines multi‑variable foreach loops with reference aliasing, enabling loops over key‑array pairs while aliasing the array.
  • Enhances the /xx regex modifier: allows multi‑line, commented character classes, but now deprecates unescaped # or vertical whitespace inside bracketed classes, emitting warnings.
  • Unicode 17.0 support tightens identifier rules; about 160 characters previously accepted under \w are rejected because they don’t meet XID_Start/Continue properties.
  • Security fixes for three CVEs (2026‑8376, 2026‑57432, 2026‑13221) addressing buffer‑overflow risks in Perl_study_chunk, large pack/unpack structures, and regex trie optimization.
  • Changes the PRNG seeding on Linux, BSD, macOS to prefer getentropy(), then /dev/urandom, then an internal hash; still not suitable for cryptographic use.
  • Performance tweaks speed up non‑overflowing integer arithmetic and hash creation from constant string keys; signature processing overhead is reduced.
  • Deprecated goto into a loop/body (since Perl 5.12) is now disallowed.
  • Support for the Perl 5.40 branch ends; the next development release (Perl 5.45.1) is expected soon, with a major stable release slated for early 2027.
2
 
 

I notice that LLMs have a strange way of writing perl.
(strange until you learn it !)

Chaining ternary operators
these seem to be used in places where i would have been more familiar with a simple if/then/else conditional.

Chaining ternary operators for compact conditionals

my $age = 27;       
     
my $category = $age < 13          ? 'child'        
                         : $age < 20          ? 'teen'     
                         : $age < 65          ? 'adult'      
                         :                            'senior';      
      
print "Category: $category\n";           
# Determine a short label for a set of unrelated inputs         
my $label = $age < 13            ? 'child'       
         : $color eq 'red'              ? 'stop'         
         : $count == 0                  ? 'empty'        
         : $mode eq 'debug'        ? 'verbose'         
         : $size > 1000                 ? 'big'         
         : 'default';          
  • When condition is true, the part after the question‑mark, becomes the value of the whole expression.

  • if true, The rest of the chain (other ternary tests) are never evaluated.

  • finally, The final : supplies the fallback value, acting as the “else” case.

  • This one‑liner is useful when you need to assign a value based on a series of mutually exclusive tests without writing explicit if/elsif/else blocks.

3
4
5
6
7
8
9
10
Perl Weekly Issue #660 (perlweekly.com)
submitted 2 years ago by to c/perl@programming.dev
11
submitted 2 years ago by to c/perl@programming.dev
12
13
14
fun with /dev/random (lemmy.sdf.org)
submitted 3 years ago* (last edited 3 years ago) by to c/perl@programming.dev
 
 

I've never had a need to use /dev/random before, but then I saw this in some documentation I was reading:

$ head -c20 /dev/random | base64
ZZXB6yF9bZvp103CI3lcREcBVEA=

Which got me thinking about my password generator. This is trivial, but I thought it was fun.

better-password-gen.pl

#!/usr/bin/env perl
use strict; use warnings; use Data::Dumper;
use feature qw< say >;

my @CList = ('a'..'z', 'A'..'Z', 0..9, split(//, q<\<\>\\/()[]{}:;"'`~#!@$%^&*-_=+>));
my $pwdLen = shift @ARGV // 12;
my $BUFF = "\x0" x $pwdLen;
open( my $RND, '<', '/dev/random' ) or die $!;
for (0..9){
    read $RND, $BUFF, $pwdLen;
    say join('', map {$CList[ord($_) % @CList]} split(//, $BUFF));
}
close($RND);

output:

$ ./better-password-gen.pl 25
M6V/$U(CGQ\p!d\lg=9>GpO[x
hlAN*"XiXnShRy)DB6GOCv;7j
NRXqeqSCZ^I\Tt2Bore4t1hYX
~4dIXVo+opRJfu6'b}u'y=N$:
6he=<mYdH'{P>Z4nDlfe4fk1T
Ffv28dOEu1fZxr9<VMhl$nS"n
yt[ol0;me'Rd2'6#ZD7!7plf[
=LZ^68!EOtP6EYJNq^;3T48HJ
V<3fcA%\b@:+"wghSX^)\S/cH
*1q08-+Zo`PHibJA<b)oeM!nx
15
submitted 3 years ago* (last edited 3 years ago) by to c/perl@programming.dev
 
 

Calendar::Simple takes a few parameters and returns an array of array refs representing the weeks and days of the month. That's it! You can use it to display text calendars, or find all of the dates for a particular day of the week for a year, or use with an HTML builder module to create a calendar web page, or whatever you want.

One caveat, which is in the documentation though I missed it, is that weeks start on Monday by default. You need that third param to specify Sunday if you want that.

I also used enum and Text::Reform

Do you have any modules you've found that really get the old brain juices flowing?

july-thru-december.pl

|               July               |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |    |    |    |  1 |  2 |
|  3 |  4 |  5 |  6 |  7 |  8 |  9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |    |    |    |    |    |    |
|              August              |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |  1 |  2 |  3 |  4 |  5 |  6 |
|  7 |  8 |  9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |    |    |    |
|            September             |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |    |    |  1 |  2 |  3 |
|  4 |  5 |  6 |  7 |  8 |  9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 |    |
|             October              |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |    |    |    |    |  1 |
|  2 |  3 |  4 |  5 |  6 |  7 |  8 |
|  9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |    |    |    |    |    |
|             November             |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |  1 |  2 |  3 |  4 |  5 |
|  6 |  7 |  8 |  9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 |    |    |    |
|             December             |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |    |    |  1 |  2 |  3 |
|  4 |  5 |  6 |  7 |  8 |  9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |

humpdays.pl

All Wednesday's in 2023
Jan: 4, 11, 18, 25
Feb: 1, 8, 15, 22
Mar: 1, 8, 15, 22, 29
Apr: 5, 12, 19, 26
May: 3, 10, 17, 24, 31
Jun: 7, 14, 21, 28
Jul: 5, 12, 19, 26
Aug: 2, 9, 16, 23, 30
Sep: 6, 13, 20, 27
Oct: 4, 11, 18, 25
Nov: 1, 8, 15, 22, 29
Dec: 6, 13, 20, 27
16
 
 

OK, why didn't anyone tell me about this module?

I do a lot of work with CSV and TSV files, usually pulling and transforming reports. My usual goto modules are Text::CSV::Slurp and when that's not enough, I use Text::CSV. Then, I do all of the data manipulation myself.

I'm finding that Data::CTable makes reading, modifying, and writing tabular data files almost trivially easy. I can act on the data row-by-row (of course) but also column-by-column. I can add, delete, re-arrange, and rename columns. I can select a subset of rows and then perform actions, like calculating the value of a new column, only on the selected rows. I can load two files and merge columns into a third, writing the result as a new CSV.

I wasn't even looking for this. I had been searching metacpan for "fixed width template" (which was satisfied with Text::Reform) when I stumbled on this module. The irony, is that it's exactly what I needed for a current work report due tomorrow!

17
 
 

I was recently reading through Perl Regular Expression Tutorial (perlretut) when I found the section on using the 'r' option. I'd seen this before but rarely had any reason to use it. Then it occurred to me that you could chain these together.

I've been programming Perl for 30+ years and don't think I've ever seen this before.

Here's an example that shows how I would usually do this, i.e. a series of var =~ s/// lines, and how to do the same thing in one line while initializing a variable.

#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';

my $T = "one two trash THREE random";
my $T2 = $T;
$T2 =~ s/trash|random//g;
$T2 =~ s/(THREE)/lc($1)/e;
$T2 =~ s/\s+/ /g;
$T2 =~ s/^/Count with me: /;

my $T3 = $T =~ s/trash|random//gr =~ s/(THREE)/lc($1)/er =~ s/\s+/ /gr =~ s/^/Count with me: /r;

say "T  := $T\nT2 := $T2\nT3 := $T3";

Output:

$ ./perl-subst-test.pl 
T  := one two trash THREE random
T2 := Count with me: one two three 
T3 := Count with me: one two three 

Anyways, I had to tell someone ...

18
 
 

At $work, we've been in the process of phasing out perl for a couple of years now, mostly in favor of go. There is still perl maintenance type work to do, and occasionally new perl code is written if it doesn't yet seem prudent to move any useful dependencies needed over to go, but I'm finding myself missing working in perl as much as I used to, and I don't currently have any side projects.

I have noticed a recent bit of activity around Padre. I've always been more of a back-end developer, so nearly everything there will be way out of my comfort zone, which seems like a good reason to see if I can dive in and learn anything in the process.

What perl things are you working on? I think this should be open to anything, even if its just a small toy, or things from $work you are allows to share, or anything else perl related.