Use perl5221delta to Check Perl 5.22.1 Regex Fixes
You will turn the perl5221delta release notes into a small smoke test for the Perl interpreter on your Linux machine. The checks cover 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.
The route
Jump straight to the step you need, or tick off Done means at the end.
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. They 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 and do not copy the sample output as though it came from your host.
2. Read the compatibility boundary before testing
The manpage says that Perl 5.22.1 has no intentionally incompatible changes relative to 5.20.0, with one deliberate exception. The exception concerns the bounds-checking constructs introduced in Perl 5.22: \b{gcb}, \b{sb}, \b{wb} and their \B{...} forms. The release fixed several bugs, including a segmentation fault.
The useful rule is precise. The \B{...} forms now match an empty string, while the \b{...} forms do not. Do not translate that into a general claim that every regular expression changed. It applies to these named boundary constructs and to the 5.22.1 implementation described by the document.
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 require an administrator, and it is separate from running the tests.
3. Check a word-boundary pattern
Run a one-line match using the \b{wb} construct. The pattern asks 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 that this 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 all Unicode word-boundary cases are correct.
Now check the contrasting empty-string behaviour of \B{wb}:
$ perl -e 'print "B-empty-match\n" if "" =~ /\B{wb}/'
B-empty-match
These commands do not write files, modify Perl configuration or contact a service. If either command 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 intended 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
This test only checks that the pattern compiles. To exercise the compiled expression as well, match 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 uses short constants and exits 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 test 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 test 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. The important result 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, not as a reason to suppress the error and continue with an undefined pattern.
6. Keep the historical result useful
Save the command output alongside the interpreter version when investigating a compatibility report. Include the distribution package version and the output of perl -V, but remove local paths or other information that your support process does not 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.
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 a request to alter a working installation. If you are building Perl from source, use its matching INSTALL documentation and test in 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 created a log while collecting results, delete that log only after checking that it contains no sensitive paths or environment data.
Done means
- You confirmed the executable, interpreter version and
perl5221deltamanpage path. - The
\b{wb}and\B{wb}checks produced the expected match lines. - The equal-bound possessive quantifier compiled and matched two
acharacters. - 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.