r/perl • • 10d ago

conferences Live, Dec 3: Poking AI, Finding a 20 years old RCE · Zoom · Luma

Thumbnail
luma.com
4 Upvotes

r/perl • • 19d ago

Perl events in November, December and beyond

20 Upvotes

r/perl • • 7h ago

Affix: FFI that makes native code feel like Perl

15 Upvotes

Affix is an FFI for Perl with a simple set of goals:

  • calling native code and dealing with raw memory should feel like writing ordinary Perl
  • it should be incredibly fast
  • the name should describe the act of binding something to something else and have 'FFI' in the dead center so you don't forget what it is

I wanted an FFI that feels good. This is what I came up with:

use v5.40;
use Affix qw[:all];
affix libc(), 'strlen', [ String ] => Size_t; # This is a terrible example but...
say strlen('hello');    # ...five.

Or maybe you're on Windows?

use Affix qw[:all];
wrap( 'user32', 'MessageBoxA', [ UInt, String, String, UInt ] => Int )->( 0, 'JAPH,', 'Hello, World', 0 );

...okay, hardly groundbreaking so far but I'm starting slow.

Affix is a bundle of amazing stuff but the type system might be the secret sauce. Primitives, enums, unions, bitfields, structs (including packed and nested structs), pointers, callbacks, variadics, wide strings, file handles, 128bit numerics, C99 complex numbers, flexible and n-dimensional arrays, and SIMD vectors are all first-class. Cast C memory and you get native Perl hashes and arrays with magic underneath, so $p->{x} = 42; writes straight into the C struct. You can even pin a scalar to an exported symbol or address in memory and read and write through it. No generated accessor methods, no copies, no ceremony.

use v5.40;
use Affix qw[:memory :types :core];
use Affix::Build;
#
my $c = Affix::Build->new;
$c->add( \<<~'C', lang => 'c' );
    typedef struct { int x; int y; } Point;
    int get_x( Point * pt ) { return pt->x; }
    int get_y( Point * pt ) { return pt->y; }
    Point new_pt( int x, int y ) { Point pt = { .x = x, .y = y }; return pt; }
    C
#
typedef Point => Struct [ x => Int, y => Int ];
affix $c->link, 'get_x', [ Pointer [ Point() ] ] => Int;
affix $c->link, 'get_y',  [ Pointer [ Point() ] ] => Int;
affix $c->link, 'new_pt', [ Int , Int ] => Point();
#
my $p = cast( malloc( sizeof Point() ), Point() );    # Allocates memory and pins a scalar to it
$p->{x} = 42;                                         # Writes directly to memory
$p->{y} = 7;
#
say get_x($p) . ' x ' . get_y($p);                    # The pin works as a pointer arg (42 x 7)
say get_x( { y => 50, x => 100 } );                   # Hashes are coerced automatically (100)
#
free $p;                                              # Auto-freed at end of scope, or freed early manually
$p->{x} = 1000;                                       # No longer bound to C memory; just a normal hashref now
#
my $p2 = new_pt(30, 25);
say $p2->{x} . ' x ' . $p2->{y};                      # struct from C is treated as a hashref (30 x 25)
say get_x($p2);                                       # Which you can turn around and hand back to native code even as a pointer (30)

In that example, I used Affix::Build which wraps compilers and build systems from Assembly to Zig to create shared libs for Affix (or even FFI::Platypus!). Think of it as Inline::C for FFI.

use v5.40;
use Affix qw[affix Int];
use Affix::Build;
#
my $c = Affix::Build->new;
$c->add( \<<~'C', lang => 'c' );
    int plus(int a, int b) { return a + b; }
    C
#
affix $c->link, 'plus', [ Int, Int ] => Int;
say plus( 2, 3 ); # ...also five.

You can even compile and link multiple languages into a single lib as long as they share similar ABIs. I'm not sure why you'd want to do that but you can.

Affix::Wrap goes the other direction: hand it C/C++ headers and it parses them using Clang's AST (with a pure-Perl fallback if you don't have LLVM installed) to generate bindings for an entire library. Bindings are ready to run immediately, or you can export them as an early draft if your project is bound for CPAN.

So, we've made native code feel like Perl but is it fast?

FFI can come with a lot of overhead but I regularly benchmark Affix against hand-written XS, Inline::C, and FFI::Platypus. Here's a quick snapshot from the latest v1.4.3 dist:

Linux x86_64 (perl v5.42.0)

  • sin(double): Affix 14.45M/s | XS 14.15M/s | Inline::C 13.31M/s | FFI::Platypus 5.32M/s
  • abs(int): Affix 11.96M/s | XS 12.24M/s | Inline::C 12.19M/s | FFI::Platypus 4.96M/s
  • strlen(const char*): Affix 11.60M/s | XS 15.35M/s | Inline::C 16.59M/s | FFI::Platypus 5.39M/s

Windows x64 (perl v5.42.3)

  • sin(double): Affix 16.60M/s | XS 5.36M/s | Inline::C 5.39M/s | FFI::Platypus 2.42M/s
  • abs(int): Affix 12.26M/s | XS 5.84M/s | Inline::C 5.89M/s | FFI::Platypus 2.30M/s
  • strlen(const char*): Affix 11.03M/s | XS 6.59M/s | Inline::C 6.59M/s | FFI::Platypus 2.41M/s

(Full multi-platform results including aarch64 and macOS are in this workflow run.)

XS can still win on very well-optimized calls, and Inline::C and FFI::Platypus are battle-tested tools that I have a lot of respect for. The point of Affix is that you don't have to trade away runtime binding, rich types, or zero-copy structs to get near-XS (or better) call throughput.

I'll try to write more about the things I'm working on. I rarely see my own projects as complete or even far enough along for a public announcement like this. To demonstrate just how silly that is, Affix has been on CPAN for five years but I've never spoken or even written about it at length outside of the project's repo. I think the projects I pick up are all cool, and it'd be nice if others thought so too, which is hard to do if no one knows they exist. My current goal for Affix is to support popular compilers on every 64bit system I can buy or find a GitHub runner for: Windows, Linux, macOS, Haiku, Solaris, Android (Termux), GNU/Hurd, and several BSDs on x64, ARM, and RISC-V so far. Part of feeling like Perl is working (when it makes sense) where Perl works.


r/perl • • 16h ago

#PeakPerl

Thumbnail
reddit.com
6 Upvotes

r/perl • • 21h ago

Debugging Legacy Perl Code

Thumbnail raku-musings.com
9 Upvotes

Finding bugs in old perl modules.


r/perl • • 22h ago

(dcxxvii) 21 great CPAN modules released last week

Thumbnail niceperl.blogspot.com
4 Upvotes

r/perl • • 1d ago

Mojolicious-MT

19 Upvotes

I dropped the 3rd of 4 drops in the perl5-MT family. Mojolicious-MT is a fork of mojo built around maximizing mojo's use of the perl5-mt runtime environment. It compares extremely favorably to node and even go. To evaluate and reproduce, take a look at mojolicious-mt-bench. The numbers are strong. This mojo fork was built with the same ethos of not breaking existing code. You can still see a performance lift without modifying your application code, but the more you lean into it the more it can give you.

https://github.com/stratum42/mojolicious-mt

https://github.com/stratum42/mojolicious-mt-bench


r/perl • • 1d ago

DBI-MT

9 Upvotes

The perl5-MT DBI fork is up on GitHub. There is one more driver that's built, but I wasn't sure if licensing and IP issues would make releasing it murky, so if anyone has more knowledge than I do and would be able to weigh in on wether or not I would get hit with a cease and desist from IBM and/or HCL, but there does exist a very highly performance optimized DBD::Informix fork since 99% of my database work is with Informix. Everything has been validated to not break existing application code as much as I could validate it. This is the last in the series of open sourcing. Keep an eye out, now that I open sourced what I could, my commercial platform I think has cleared the last ethical hurdle for commercial launch and it's all built on perl and XS, with a splash of Go for flair. I hope the community can make use of what I made in some way.

https://github.com/stratum42/dbi-mt

https://github.com/stratum42/dbi-mt-bench

https://github.com/stratum42/dbd-sqlite-mt

https://github.com/stratum42/dbd-odbc-mt


r/perl • • 1d ago

Perl5-MT GUI via Tcl::Tk::MT

11 Upvotes

https://github.com/stratum42/app-codit-mt

https://github.com/stratum42/tkmark

https://github.com/stratum42/neon-bastion

https://github.com/stratum42/tcl-tk-mt

This is the second of 4 drops in the Perl5-MT series. I'm slowly releasing things to make sure they're tight. I've taken great pains to ensure proper attribution to the original projects the code is derived and/or forked from, which takes time. If somehow I made a mistake and missed proper attribution or got a detail incorrect, I promise it was not intentional. Please let me know so I can correct the error. With tcl-tk-mt and perl5-mt you too can create mindless, terrible 2d games at ridiculous FPS in perl, or do productive clean Perl GUI application development, your choice. Perl5-MT is unchanged and I still am not sure how to actually make it fully win64 native, but I left the paths in these projects so that when it is, subject to community involvement, the upstream part should at least be hypothetically ready.

tcl-tk-mt is built the same way as perl5-mt, from the ground up designed not to break existing applications. There's better performance to be had by using more of both, but you can still get gains without changing a single line of your own application code.

All the credit belongs with the people who have made the projects these forks are based on. I'm not personally identifying myself or attempting to claim any ownership or authorship over their intellectual contributions. They did the hard work, I did the relatively easier part of making their work faster.


r/perl • • 2d ago

Best place to find Perl developers for hire?

39 Upvotes

My business needs some additional resource in the short-medium term from an experienced Perl developer. I'm at a bit of a loss as to where to find one, given that it's now somewhat niche and most people searching for jobs are not advertising experience with Perl.

As recommended by u/ysth, some details:

- Remote, UK (open to elsewhere but must have fluent English)
- Open to commercials whether a fixed-term agreement, or ad-hoc for added flexibility
- Maintenance and developing on legacy perl websites/web applications

Does anyone have any recommendations?


r/perl • • 2d ago

perl5-mt: a Perl 5.40.2 fork with shared-memory threads, fibers, XS fault isolation, and SIMD

24 Upvotes

I've been working on a fork of Perl 5.40.2 called perl5-mt and just pushed it to GitHub: https://github.com/stratum42/perl5-mt

Perl has enabled me to do a ton over the years, and I built this mostly to solve the things that kept biting me on modern multi-core machines without throwing away decades of existing Perl code. The main idea is freezing the loaded program into a read-only boot image (mprotect / Intel MPK) shared across OS worker threads instead of cloning the whole interpreter like ithreads does. On top of that there are stackful M:N fibers (MT::Fiber), lock-free cells and channels, and an async I/O layer (:async / MT::IO).

The part I probably spent the most energy on is fault tolerance and keeping old CPAN XS usable. Thread-safe XS runs directly in workers, while legacy non-thread-safe XS gets routed into pre-forked out-of-process compartments (PERL_MT_XS_SPARES). If a bad C library crashes a compartment, a spare gets promoted and reloads the module in about 5 ms instead of taking down the whole process. Workers also run on their own sigaltstack so a SIGSEGV/SIGBUS/SIGFPEunwinds cleanly to the worker root without touching sibling workers, and there is heartbeat supervision (MT::Supervisor), supervised pools with backoff, explicit checkpoints, and warm primary/backup process pairs (pairs => 1), plus partition/namespace/resource-class controls (MT::SharedImage, MT::Namespace, MT::Class, MT::Partition).

While I was in the guts of the interpreter, I also added SwissTable hashes behind HV (PERL_MT_SWISS=0 to toggle off), packed typed arrays (MT::Array), SIMD kernels for bytes/UTF-8/regex spans, deterministic cross-host binary64 math (core-math, Eisel-Lemire, optional Ryu, canonical qNaN) plus MT::Decimal, an offload layer (MT::Accel) with live macOS Accelerate and AMD/Intel Mesa OpenCL support, and -Dusepgo / -Dusenative Configure targets.

Both macOS arm64 and Linux x86_64 pass the upstream make test_harness (~1.2M tests each, zero runtime failures) and produce identical cross-host SHA-256 numeric digests in t/mt/num_digest.t. There's a standalone benchmark script (./perl -I. -Ilib tools/bench-suite.pl) if you want to test it on your own box, and measured numbers from both machines (including PGO) are in MT_BENCH.md. I also wrote native backends for AIX, IBM i PASE, and z/OS USS (ASCII and EBCDIC), though those and some of the extra GPU/NPU/coprocessor offload slots haven't been run on real hardware yet, so if anyone here still has access to that iron and wants to kick the tires I'd love to hear how it goes.

I'm one person so I can't promise to maintain or extend it beyond my own needs, but if any of this is useful to you or worth picking apart for upstream ideas, have at it. Architecture notes are in MT_DESIGN.md.


r/perl • • 2d ago

question How long before a Perl2Shell exploit?

19 Upvotes

Just in the past couple of weeks we've had Php2Shell, Java2Shell and now Ruby2Shell.

How long before the AI researchers turn their guns on Perl?


r/perl • • 5d ago

Perl Weekly Issue #799 - Programming (Perl) using AI?

Thumbnail
perlweekly.com
21 Upvotes

r/perl • • 5d ago

proposal for a 'two_arg_open' unfeature by book · Pull Request #96 · Perl/PPCs

Thumbnail github.com
8 Upvotes

r/perl • • 6d ago

Thanksgiving release cleanout

Thumbnail corion.net
15 Upvotes

Corion writes

Twice a year, around Thanksgiving and Spring, I take stock of all the code that has amassed on my systems. I usually try to release it on CPAN, or at least publish it on GitHub, if not as a way of giving back to the community then at least as another off-site backup.


r/perl • • 8d ago

(dcxxvi) 16 great CPAN modules released last week

Thumbnail niceperl.blogspot.com
10 Upvotes

r/perl • • 8d ago

conferences FOSDEM 2027 Call for Participation

Thumbnail reddit.com
10 Upvotes

r/perl • • 10d ago

The publication of the second edition of "Data Munging with Perl" just got a whole lot closer!

Thumbnail
gallery
196 Upvotes

r/perl • • 11d ago

I built a tool to visualize Perl codebases — Perl::CodeMap (now on CPAN)

57 Upvotes

I've been working with a fairly large legacy Perl codebase and wanted an easier way to explore dependencies and understand how everything fits together.

I came across CodeMap for Go and decided to put together a Perl version.

It uses PPI to analyze source code and generates an interactive HTML visualization with dependency graphs, searchable modules and subroutines, and syntax-highlighted source browsing.

It's still a work in progress, but I've found it useful for navigating unfamiliar code. Figured others dealing with large Perl projects might find it useful too.

Feedback and suggestions welcome.


r/perl • • 11d ago

Factoring integers in Perl, thirteen years later

Thumbnail blogs.perl.org
36 Upvotes

r/perl • • 12d ago

Perl Weekly Issue #798 - LPW 2026

Thumbnail
perlweekly.com
19 Upvotes

r/perl • • 12d ago

NetAddr::IP 4.080_08: another trial, please smoke test

Thumbnail blogs.perl.org
4 Upvotes

r/perl • • 15d ago

(dcxxv) 19 great CPAN modules released last week

Thumbnail niceperl.blogspot.com
13 Upvotes

r/perl • • 18d ago

XS coverage for Perl

Thumbnail
lnation.org
22 Upvotes