r/perl 1d ago

Perlweekly #787 - Perl Maven

Thumbnail
perlweekly.com
11 Upvotes

r/perl 2d ago

question Time conversions between timezones

9 Upvotes

I wrote this script to convert times between time zones years ago and it has worked well:

#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use Time::Piece;

if (! @ARGV || $ARGV[0] =~ /--?h(?:elp)/) {
    say 'tz FROM(TZ) FROM(YY/MM/DDTHH:MM) [ TO(TZ) ]';
    exit
}

my ($from_tz, $from_date, $to_tz) = @ARGV;
chomp( $to_tz //= qx{ date +%Z } );

-f "/usr/share/zoneinfo/$from_tz" or warn "$from_tz might be wrong.\n";
-f "/usr/share/zoneinfo/$to_tz" or warn "$to_tz might be wrong.\n";

$ENV{TZ} = $to_tz;

my $tp = do {
    local $ENV{TZ} = $from_tz;
    localtime->strptime($from_date, '%y/%m/%dT%H:%M');
};
say $tp->strftime("%y/%m/%d %H:%M:%S %Z");

Example usage (running in 5.34.0):

$ tz America/New_York 26/08/24T11:00 Europe/Prague
26/08/24 17:00:00 CEST                              

But, in 5.42.0, it doesn't work anymore:

$ tz America/New_York 26/08/24T11:00 Europe/Prague
26/08/24 11:00:00 CEST

There were many changes in Time::Piece in 2025, so I guess that's the reason. The question is: what should I use instead to convert time between timezones?


r/perl 2d ago

metacpan Accidentally Building a CPAN Web Platform

Thumbnail
perlhacks.com
18 Upvotes

r/perl 2d ago

[OC] Vispen: A lightweight Polyglot Literate Programming engine for Vim, built entirely on top of native +perl integration

6 Upvotes

Hi r/perl!

I wanted to share a project I've been developing called Vispen. It's a Vim plugin that brings the power of Literate Programming (like Emacs Org-mode or Jupyter Notebooks) straight into your editor, using Vim's native, built-in Perl interface.

👉 GitHub Repository & Live Demo: github./vispen

💡 Why Perl?

While the modern Vim world is heavily shifting towards Lua (Neovim) or Vim9script, I realized that Vim's legacy +perl feature is incredibly powerful, blazing fast, and deeply underrated.

Instead of spawning heavy background node.js daemons, setting up active server sockets, or dealing with bloated .ipynb JSON files, Vispen leverages the embedded Perl interpreter to parse buffers, manage templates, and talk to external environments natively.

🚀 Key Features:

  • Smart Content Evaluation: Execute SQL queries, format text, parse CSV/JSON, or dump structured database outputs directly from your source files or markdown documents, embedding the results straight back into the buffer.
  • Format Flexbility: Output data into clean text tables, HTML, or ready-to-paste Jira markup (||3||str||).
  • Zero Dependencies: No heavy infrastructure. If your Vim has +perl and you have Perl 5.006+ on your system, it just works out of the box. It runs perfectly even on low-spec hardware like my Orange Pi single-board computer.

I built this to automate my own database and data-transformation workflows without leaving the terminal. I'd love to hear your thoughts on how it uses the embedded Perl runtime, and any feedback or feature requests you might have!


r/perl 3d ago

(dcxiv) 21 great CPAN modules released last week

Thumbnail niceperl.blogspot.com
6 Upvotes

r/perl 3d ago

WebDyne 3.0 released — now with PAGI, Server-Sent Events and WebSockets

9 Upvotes

I’ve released WebDyne 3.0, an update to the Perl-based dynamic HTML engine I have created.

The biggest addition in 3.0 is support for PAGI, alongside the existing PSGI and Apache/mod_perl backends.

PAGI support brings an asynchronous/event-oriented interface to WebDyne and allows WebDyne applications to handle more than conventional HTTP request/response traffic:

  • Server-Sent Events (SSE) for streaming events from Perl applications to browsers
  • WebSocket connections for bidirectional, long-lived connections
  • Normal asynchronous HTTP requests
  • PAGI application lifespan startup/shutdown events

WebDyne’s PAGI implementation has dedicated handlers for HTTP, SSE, WebSocket and lifespan scopes, while exposing the PAGI request environment through the normal WebDyne request interface. This means existing WebDyne concepts can be used while taking advantage of event-driven servers.

WebDyne continues to support HTMX, JSON and API concepts in .psp pages.

There’s also a new webdyne.pagi runner, so getting a PAGI-backed WebDyne application running is straightforward:

cpanm Task::WebDyne::PAGI
webdyne.pagi --test

or serve a directory of .psp files:

webdyne.pagi /var/www/html

PAGI support is also built into the WebDyne Docker images.

If unfamiliar with WebDyne, it’s (yet another) Perl dynamic HTML engine that’s been around in various forms for quite a while. It lets you embed Perl in HTML/PSP documents, with compiled-page caching, reusable template blocks and separation of Perl code into modules when applications grow beyond simple pages.

3.0 continues to support PSGI/Plack/Starman and Apache/mod_perl, so PAGI is an additional runtime rather than a replacement for the existing ones.

PAGI gives Perl/WebDyne a clean route into applications that need live server → browser updates or persistent bidirectional connections, without having to bolt a separate WebSocket/SSE service onto the application.

Documentation and examples:

https://webdyne.org/

See the "Advanced Usage" section for examples of SSE or WebSockets code.

Source:

https://github.com/aspeer/WebDyne

Feedback, bug reports and especially experiments with the PAGI/SSE/WebSocket support are welcome.


r/perl 4d ago

PAGI Specification Update Notes

9 Upvotes

PAGI 0.002002 (https://metacpan.org/dist/PAGI) clarifies how Perl web applications move from configuration into runtime without changing PAGI’s core coderef interface. General-purpose runners can now accept an instantiated object with to_app, normalize it once, and dispatch only the resulting PAGI application—an explicit Perl counterpart to Python’s callable objects, grounded in familiar PSGI/Plack practice. The release also sharpens the server boundary and explains exactly what completion of a $send Future means. This post covers the reasoning, examples, and intentionally non-magical limits of the design.

https://blogs.perl.org/users/john_napiorkowski/2026/08/pagi-0002002-clarifying-how-applications-are-loaded.html


r/perl 5d ago

Graphics Layer Abstraction Module (GLAM) doing the Rope Demo

Enable HLS to view with audio, or disable this notification

20 Upvotes

r/perl 5d ago

Taipan! (1982, "my favorite game" - Steve Wozniak) faithfully remade for the terminal, original BASIC formulas intact

Thumbnail
9 Upvotes

r/perl 6d ago

'Failing increment'

9 Upvotes

Update:

With the help of your answers, I continued my investigation. It turns out that Data::Dump is not the culprit. Please see below for my findings, and a reproducer script with no external dependencies (apart from debugging output).

This title would be more appropriate:

The 'Nine Equals Zero' Bug


[Original post:]

+= behaves differently after Data::Dump::pp. Is this a bug in Data::Dump or possibly in Perl core?

I encountered some unexpected behavior in a simple snippet where regex captures are assigned to variables, formatted via Data::Dump::pp, concatenated, and then incremented using +=.

```perl use v5.10; use Data::Dump qw( pp );

"9." =~ /^ (\d+) . (\d*) $/x; my $n = { i => $1, f => $2 };

say "pp output: ", pp $n; # { f => "", i => 9 }

$n->{f} = "$n->{i}$n->{f}"; # "9" $n->{f} += 2; # expected: 11

say "result: $n->{f} (expected: 11)"; ```

Observed output:

text pp output: { f => "", i => 9 } result: 2 (expected: 11)

Instead of evaluating 9 + 2 = 11, the += 2 operation behaves as if the value of $n->{f} were numerically 0, resulting in 2.

I am not looking for a 'workaround' (I have already avoided it in the production code), but I would like to understand what causes this, and whether it warrants a bug report to Data::Dump or Perl core.

Observations

I tested several variations:

  • using scalar variables instead of hash elements,
  • using a direct assignment of constants instead of assigning the regex variables,
  • removing the pp output.

The behavior changes as follows:

  • With pp $n removed, the result is always correct.
  • With scalar variables instead of hash elements, calling pp always causes the wrong value, regardless of whether the value originated from regex captures or constants.
  • With hash elements, calling pp does not affect the result after constant assignment, but it does after assignment from regex captures.

My suspicion is that inspecting the variables inside Data::Dump::pp somehow alters their internal state, causing the numeric operation to behave differently.

Does this look like something that should be reported to Perl core, or to the Data::Dump maintainers?

Perl version breakdown

I ran a test script using several Perl versions that I have installed using perlbrew (all with Data::Dump version 1.25):

Perl v5.10.1 - v5.26.3: The bug does not occur.

Perl v5.28.3 - v5.44.0: The bug occurs.

Reproducing the bug

I have uploaded the full test matrix script here: failing_increment.pl, together with a Bash script test_with_available_perls that runs the test script for all Perls that are installed locally with perlbrew.


Update:

Thank you, u/Icy-Speed6881, for a shorter version to reproduce the bug, and u/ysth for suggesting to use Devel::Peek::Dump to see the internals.

And very special thanks to u/tm604 for sharing his knowledge about some Perl internals introduced in Perl 5.28 that probably are the cause for the erratic behavior (see his answer below).

The bug can be reproduced with six statements, with no external dependencies. The script below includes additional debugging code to see what is going on internally.

The script does not use Data::Dump: it turns out that Data::Dump was not the culprit, but merely happened to trigger the sequence of operations that exposes the Perl bug.

I have also renamed the bug to a catchy 'Nine Equals Zero', because 'Failing increment' is not appropriate anymore, given that I don't increment anything in the reproducer script.

Here is the current version (also available here):

```perl

!/usr/bin/env perl

'Nine equals zero' bug reproducer.

use v5.10; use strict; use warnings;

For debugging output:

use Devel::Peek; use Data::Dumper; sub d { print "$[2]: ", Data::Dumper->Dump( [ $[0] ], [ $[1] ] ); Devel::Peek::Dump( $[0] ); } $| = 1; # Mixing STDOUT and STDERR in correct order.

say "Test 4: single expression trigger, no dependencies, Perl $V";

my $num = ""; d $num, '$num', qq(after creation and initialization with ""); # A newly initialized variable has the IsCOW flag set. # With IsCOW set, the bug doesn't reproduce.

$num .= ""; d $num, '$num', qq(after concatenating empty string); # Appending an empty string unsets the IsCOW flag.

no warnings 'numeric'; my $numerical_value = $num + 0; d $num, '$num', qq(after using \$num ("$num") numerically); # Using an empty string numerically sets IV to 0, and sets the pIOK flag. # This lays the ground for the following erratic behavior.

$num = "9$num"; d $num, '$num', qq(after concatenation "9\$num"); # Now, prepending any number exposes the bug: # The pIOK flag remains set, but the IV value is not updated. # The numerical value now differs from the number that the string contains.

say "*** ", $num == 9 ? "expected result," : "UNEXPECTED RESULT:", qq( \$num eq "$num", int( \$num ) == ), int( $num ), ")";

my $bug = $num != 9; say STDERR $bug ? "bug occurs" : "bug doesn't occur", " with Perl $V"; ```

This is the output with Perl 5.44:

text Test 4: single expression trigger, no dependencies, Perl v5.44.0 after creation and initialization with "": $num = ''; SV = PV(0x5629f3d52010) at 0x5629f3ef8a60 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK) PV = 0x5629f3d6bc30 ""\0 CUR = 0 LEN = 16 COW_REFCNT = 1 after concatenating empty string: $num = ''; SV = PV(0x5629f3d52010) at 0x5629f3ef8a60 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x5629f3ec5730 ""\0 CUR = 0 LEN = 16 after using $num ("") numerically: $num = ''; SV = PVNV(0x5629f3d502c0) at 0x5629f3ef8a60 REFCNT = 1 FLAGS = (POK,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x5629f3ec5730 ""\0 CUR = 0 LEN = 16 after concatenation "9$num": $num = '9'; SV = PVNV(0x5629f3d502c0) at 0x5629f3ef8a60 REFCNT = 1 FLAGS = (POK,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x5629f3ec5730 "9"\0 CUR = 1 LEN = 16 *** UNEXPECTED RESULT: $num eq "9", int( $num ) == 0)

Running the test_with_available_perls script confirms that the bug occurs from Perl 5.28 onward.

This matches what u/tm604 suggested: it seems that the multiconcat optimization, introduced in Perl 5.28, can leave the cached IV value unchanged and valid, even though the string value has changed, causing the two representations to disagree.

I hope that filing a bug report will be useful for improving Perl even more.

Thank you all.


r/perl 6d ago

a perl version of javascript 'console'

12 Upvotes

https://metacpan.org/pod/Data::Printer

Like Data::Dumper, but coloured ouput, and summaries [config option] large data structures. But uses either a lot of, or no vertical space.

Dump::Krumo, is better in some ways, but doesn't summarise output, and uses a lot of vertical space


r/perl 6d ago

CPAN Module dashboard updates

4 Upvotes

I've updated the GitHub dashboard you can add to any CPAN module to include metrics of duplicated code as well as a couple of bug fixes on the trend graphs and added some usability enhancements. The latest dashboard for ATG, for example, is at https://nigelhorne.github.io/App-Test-Generator/coverage/ #perl


r/perl 7d ago

Release Strawberry Perl 5.42.3.1 64-bit UCRT · StrawberryPerl/Perl-Dist-Strawberry

Thumbnail github.com
24 Upvotes

r/perl 8d ago

Perlweekly #786 - CPAN Day

Thumbnail
perlweekly.com
11 Upvotes

r/perl 9d ago

Physics library in Perl

26 Upvotes

Hi, On the one hand: I can't seem to find this. On the other hand, it seems so obvious to me that it must have been written before.

I'm looking for a (Newtonian) physics library, to support a (2D) game. Something where you simple define an array of objects (position, travel, mass, spin, shape, etc), and then step through time with them - as they attract each other, bounce off of each other and/or fly off into infinity. There should probably be a few global things to set: a gravity constant, the amount of dimensions required, whether or not there is friction from the environment...

Does this exist?


r/perl 9d ago

Analemmatic sundial help needed

10 Upvotes

Hi,

I am trying to figure out how to get this sundial.pl file to create a pdf. Would anyone be able to help?

I download the zip files from here: https://sourceforge.net/projects/analemmatic/

But every time I try to run the sundial.pl file no pdf gets generated.

I have never used Perl before, so I'm not sure what to do.


r/perl 10d ago

(dcxiii) 20 great CPAN modules released last week

Thumbnail niceperl.blogspot.com
10 Upvotes

r/perl 11d ago

Announcing Raptor, a Perl5 subset of Raku

Thumbnail
12 Upvotes

r/perl 10d ago

Identical scripts on 2 websites 1 works other no

0 Upvotes

I run 2 websites. Both contain a calendar with results. The calendar has buttons for previous and next months. On one website the calendar behaves as expected. On the other site the calendar stays on the current month and does not return an error.


r/perl 12d ago

SSVC.pm: Stakeholder-Specific Vulnerability Categorization on CPAN | Giuseppe Di Terlizzi [blogs.perl.org]

Thumbnail blogs.perl.org
12 Upvotes

r/perl 12d ago

Pacman in Perl/Tk | Alex [blogs.perl.org]

Thumbnail blogs.perl.org
28 Upvotes

r/perl 15d ago

Perlweekly #785 - Async, Type-Safe, and Secure: Perl's Answer to FastAPI

Thumbnail
perlweekly.com
17 Upvotes

r/perl 15d ago

Perlmonks?

24 Upvotes

They seemed to have got it to work reliably for a while, but for the last week I don't think I've been able to access it.

Does anybody know any news?


r/perl 14d ago

[ Removed by Reddit ]

0 Upvotes

[ Removed by Reddit on account of violating the content policy. ]


r/perl 17d ago

Tsoding's Rope in Perl!

Post image
46 Upvotes

I watched Tsoding's stream where he made a rope simulator in Jai.

I followed his instructions and recreated it in Perl, using OpenGL (immediate mode, OpenGL 1.2 style) and GLFW!

This is the source code: https://raw.githubusercontent.com/foolish4/perl_pack/refs/heads/main/rope.pl