r/perl

▲ 12 r/perl

Graphics Layer Abstraction Module (GLAM) doing the Rope Demo

u/saiftynet — 10 hours ago
▲ 2 r/perl

'Failing increment'

+= 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 +=.

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:

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.

Thank you for your help!

reddit.com
u/muthm59 — 1 day ago
▲ 23 r/perl

Physics library in Perl

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?

reddit.com
u/RedWineAndWomen — 5 days ago
▲ 25 r/perl+2 crossposts

Announcing Raptor, a Perl5 subset of Raku

I have been experimenting a lot with LLMs and new programming languages. Most of my experiments have been around extending C with multimethod and a better cpp. Minimal languages like tcl, lisp, forth are super easy to prototype with LLMs.

Because of the way RLVR works I think Perl5 makes an excellent language like go/C for LLM generation. LLMs learn to write code by making tests pass.

After experimenting with PEG grammars with pigeon in go, I decided to give moarvm a try. I like Raku but I like Perl5 even more. Although I never programmed in Perl professionally, it was my first language. I made the first port of Perl (miniperl) to asm.js back in the day.

Raptor is a dynamic language - roughly a Perl5 subset of Raku targeting Wasm, Go and MoarVM. It supports go FFI, C FFI, refinement types, predicate types, multimethods, defensive programming, literate programming and standalone binary packaging (raptor pack). These are the features I have always wanted in Perl. There's rudimentary wasm support. There's also PHP mode.

If you know Raku then you already know raptor. Raptor will never support OO like Raku or PyObject like Python. I intend it to support C FFI thoroughly and a strict procedural style along with universal function calling syntax. That's probably the main difference between Raptor and Raku.

I think the future of programming will be to make languages with parsable grammars, good verification support and must include literate programming for humans.

The language was mostly written by Anti Gravity - Gemini 3.6. Library bindings, podlit are written by Gemini 3.7 which was released today. My role was just in pushing it to implement more tests.

I have mostly built this on windows. It should work on Linux. Expect bugs, memory leaks and probably some wrong semantics. Future versions will make it closer to Raku.

https://github.com/xyzzyapps/raptor

https://xyzzyapps.github.io/raptor/

u/No_Pianist1870 — 6 days ago
▲ 0 r/perl

Identical scripts on 2 websites 1 works other no

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.

reddit.com
u/Rvamp — 6 days ago
▲ 25 r/perl

Perlmonks?

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?

reddit.com
u/tobotic — 11 days ago