Home / Alt manpages / perl5221delta(1)

  • perl5221delta(1)
  • User command
  • linux

Use perl5221delta to Check Perl 5.22.1 Regex Fixes

perl5221delta records exactly which regex boundary constructs used to cause a segfault. This guide turns those release notes into a small smoke test for the Perl interpreter on your Linux machine, covering word-boundary regular expressions, possessive quantifiers and malformed patterns that should fail cleanly. Allow about fifteen minutes. You need Perl and the perl-doc package; no root access is required.

This is a release-note guide, not an upgrade procedure. The installed manpage describes differences between Perl 5.22.0 and 5.22.1. On this machine it is generated from Perl 5.38.2, so the package is newer than the release being described. That distinction matters: a passing check shows what the current interpreter does, not that an old system has been upgraded.

1. Confirm which Perl and manpage you are testing

Start with read-only checks that show the executable selected by your PATH, the interpreter version, and the package providing the release notes:

$ command -v perl
/usr/bin/perl
$ perl -e 'printf "%vd\n", $^V'
v5.38.2
$ dpkg-query -W -f='${Package} ${Version}\n' perl perl-doc
perl 5.38.2-3.2ubuntu0.6
perl-doc 5.38.2-3.2ubuntu0.6
$ man -w perl5221delta
/usr/share/man/man1/perl5221delta.1.gz

The version in the manpage header is Perl 5.38.2 on this installation, even though the document title discusses Perl 5.22.1. Read the document as historical compatibility information. If your distribution reports a different version, keep that version in your notes rather than copying the sample output as though it came from your own host.

2. Read the compatibility boundary before testing

The manpage says Perl 5.22.1 has no intentionally incompatible changes relative to 5.20.0, with one deliberate exception: the bounds-checking constructs introduced in Perl 5.22, \b{gcb}, \b{sb}, \b{wb} and their \B{...} forms. The release fixed several bugs there, including a segmentation fault.

The rule is precise rather than sweeping: the \B{...} forms now match an empty string, while the \b{...} forms do not. That is not a general claim that every regular expression changed; it applies specifically to these named boundary constructs in the 5.22.1 implementation.

Checkpoint

Display the relevant section without changing anything:

$ man perl5221delta
$ man perlrebackslash

If man cannot find the page, install the distribution's documentation package through your normal package-management process. That is the only step in this guide that might need an administrator, and it is entirely separate from running the tests.

3. Check a word-boundary pattern

Run a one-line match using the \b{wb} construct, asking for a word boundary before and after the letter a:

$ perl -e 'print "word-boundary-match\n" if "a" =~ /\b{wb}a\b{wb}/'
word-boundary-match

A successful line confirms the interpreter accepts the syntax and finds the expected boundary around a one-letter word. It is a functional check, not a benchmark, and not proof that every Unicode word-boundary case is correct.

Now check the contrasting empty-string behaviour of \B{wb}:

$ perl -e 'print "B-empty-match\n" if "" =~ /\B{wb}/'
B-empty-match

Neither command writes files, modifies Perl configuration or contacts a service. If either fails, record the complete error and the output of perl -V; a locally installed module or wrapper may be selecting a different interpreter than the one you expected.

4. Check the possessive-quantifier regression

The release notes describe a Perl 5.20 regression in possessive quantifiers when the minimum and maximum repetition counts were equal. A form such as a{2,2}+ is meant to behave like the equivalent atomic grouping. Compile the pattern inside eval so the check reports a result instead of terminating your shell command:

$ perl -e 'my $ok = eval q{ qr/a{2,2}+/; 1 }; print $ok ? "possessive-ok\n" : "possessive-failed: $@"'
possessive-ok

That only checks the pattern compiles. Exercise the compiled expression as well by matching it against exactly two characters:

$ perl -e 'my $re = qr/a{2,2}+/; print "two-a-match\n" if "aa" =~ $re'
two-a-match

Do not use untrusted regular expressions in a production process merely because they compile. Complex expressions can still consume significant CPU or memory; this guide sticks to short constants that exit immediately.

5. Confirm malformed patterns fail as errors

Several selected fixes concern parser crashes and syntax errors that used to be accepted or could cause a panic. The safe way to probe those cases is to compile the pattern under eval and inspect the error text. First, an unterminated flag group:

$ perl -e 'my $ok = eval q{ qr/(?i/; 1 }; print $ok ? "malformed-accepted\n" : "malformed-rejected: $@"'
malformed-rejected: Sequence (?... not terminated in regex; marked by <-- HERE in m/(?i <-- HERE / at (eval 1) line 1.

Next, an incomplete extended bracketed character class:

$ perl -e 'my $ok = eval q{ qr/(?[ ])/; 1 }; print $ok ? "bracket-accepted\n" : "bracket-rejected: $@"'
bracket-rejected: Incomplete expression within \'(?[ ])\' in regex; marked by <-- HERE in m/(?[  <-- HERE ])/ at (eval 1) line 1.

The exact diagnostic wording can vary between Perl releases; what matters is rejection through eval, with the shell command itself completing normally. In a program, treat a failed compilation as input or deployment data to fix, never as a reason to suppress the error and carry on with an undefined pattern.

6. Keep the historical result useful

Save the command output alongside the interpreter version when investigating a compatibility report, including the distribution package version and the output of perl -V, but strip out local paths or other detail your support process doesn't need. Compare like with like: a Perl 5.22.0 result is relevant to the release notes, while a Perl 5.38.2 result is evidence about the newer interpreter's behaviour instead.

Do not change PERL_HASH_SEED, rebuild Perl or add the NO_HASH_SEED define just to exercise the configuration fixes in this document. Those notes concern interpreter compilation, and the manpage's examples are not an instruction to alter a working installation. Building Perl from source is a job for its matching INSTALL documentation and an isolated build directory.

There is nothing to undo from these commands: they compile patterns in short-lived processes and leave no configuration behind. If you kept a log while collecting results, delete it only after checking it holds no sensitive paths or environment data.

Done means

  • You confirmed the executable, interpreter version and perl5221delta manpage path.
  • The \b{wb} and \B{wb} checks produced the expected match lines.
  • The equal-bound possessive quantifier compiled and matched two a characters.
  • The malformed flag group and bracketed class were rejected through eval, without a process crash.
  • Your notes distinguish Perl 5.22.1's historical fixes from the behaviour of the newer interpreter you actually tested.