Home / Alt manpages / perl5280delta(1)

  • perl5280delta(1)
  • User command
  • linux

Check Perl 5.28 Changes Before You Rewrite Scripts

You will finish with a small, repeatable check for Perl 5.28-era code: confirm the interpreter version, exercise the useful language changes, test a safe in-place edit on a disposable file, and identify syntax that may break during an upgrade. The commands below change only files under /tmp.

Prerequisites and checkpoint

You need a shell and the perl interpreter. The installed documentation comes from the perl-doc package. Allow about 10 minutes if you are checking one script, or 30 minutes for a small codebase. No command here needs root privileges.

Checkpoint 1: stop after this step if the interpreter is older than the feature level you intend to use.

  1. Record the interpreter and documentation version.

    perl -v
    perl -MConfig -e 'print "$Config{version} $Config{archname}\n"'
    man perl5280delta | sed -n '1,35p'

On this machine the installed interpreter is Perl 5.38.2, while perl5280delta describes the changes from Perl 5.26.0 to 5.28.0. That distinction matters: running a 5.28 example successfully on 5.38 proves that the newer interpreter accepts it, not that every 5.28 patch release behaves identically. If you need to support exactly 5.28, run the same checks with that interpreter in a test environment.

Check the feature bundle and persistent state

Perl 5.28 makes the bitwise feature available through use v5.28. It also allows a persistent lexical array or hash to have an initial value. Put both in a short compile-and-run check before moving them into production code.

  1. Run a self-contained feature check.

    perl -we '
    use v5.28;
    use strict;
    use warnings;
    state @names = qw(alice bob);
    my $mask = 0b1010;
    my $value = 0b1100;
    print join(",", @names), "\n";
    print (($mask & $value) == 8 ? "numeric bitwise: OK\n" : "numeric bitwise: FAIL\n");
    my $text = "AB";
    print (($text ^. "  ") eq "ab" ? "string bitwise: OK\n" : "string bitwise: FAIL\n");
    '
    

Expected output is:

alice,bob
numeric bitwise: OK
string bitwise: OK

The dot in ^. is significant. The dotted operators are string-specific; the undotted operators are number-specific inside the feature scope. The whitespace after the operator is optional, but the dot is not.

Common trap: the numeric operators can pass an additional true argument to overloaded methods. If an object class or XS extension counts the arguments received by its bitwise overload handler, test that class rather than assuming ordinary scalars are representative.

Use Unicode script checks deliberately

Perl 5.28 adds experimental regular-expression assertions for script runs. They can reject a word whose characters mix scripts, which is useful when an identifier or account name should not contain look-alike characters. They are experimental, so expect a warning unless you handle that warning category explicitly.

  1. Compile a script-run pattern and print whether it matches.

    perl -we '
    use v5.28;
    use utf8;
    no warnings "experimental::script_run";
    my $word = "server";
    if ($word =~ /\A(*sr:\w+)\z/) {
        print "single script: OK\n";
    } else {
        print "mixed or unsupported script\n";
    }
    '
    

Expected output:

single script: OK

This is not a complete spoofing defence. It checks the matching rule you wrote, not whether a name is safe for your application, language or display font. Keep normal Unicode validation and review rules around it.

Test the safer perl -i behaviour

Perl 5.28 changed in-place editing so the original is replaced only after the new file has been written and closed successfully. It creates a work file in the same directory before the final rename. That reduces the chance of losing the input after a write failure, but -i still changes data and is not a substitute for a backup.

  1. Create a disposable file, edit it with a backup suffix, and inspect the result.

    printf '%s\n' 'DEBUG=1' 'PORT=8080' > /tmp/perl5280-demo.conf
    perl -pi.bak -e 's/^DEBUG=1$/DEBUG=0/' /tmp/perl5280-demo.conf
    printf '%s\n' 'edited:'
    cat /tmp/perl5280-demo.conf
    printf '%s\n' 'backup:'
    cat /tmp/perl5280-demo.conf.bak
    test "$(sed -n '1p' /tmp/perl5280-demo.conf)" = 'DEBUG=0'
    test "$(sed -n '1p' /tmp/perl5280-demo.conf.bak)" = 'DEBUG=1'
    echo 'in-place edit: OK'

Expected output includes the edited and backup contents, followed by in-place edit: OK. The backup suffix is a safety net, not permission to run an unreviewed substitution across a production tree. Check the target list first, quote paths containing spaces, and keep the edit in the same filesystem so the final rename can succeed.

Recovery

While this demonstration file is disposable, the reversible pattern is mv /tmp/perl5280-demo.conf.bak /tmp/perl5280-demo.conf. For real data, stop and restore from your normal backup after checking the backup file, ownership and permissions. Do not run that command against a path you have not inspected.

Check upgrade-sensitive code

The delta document also records compatibility changes that do not produce a useful one-line feature demo. Search your source for subroutine signatures with attributes, bare here-document terminators, format lists without commas, empty \N{}, and the removed sort subpragmata _mergesort, _quicksort and _qsort. These were deprecated, removed or made stricter in 5.28.

  1. Search a checked-out project without changing it.

    rg -n --glob '*.pl' --glob '*.pm' --glob '*.t' \\
      'sub\\s+\\w+\\s*\\([^)]*\\)\\s*:(?:lvalue|method)|_mergesort|_quicksort|_qsort|\\N\{\}' .

A match is a review item, not proof of a bug. Read the surrounding code and run the project's test suite under each supported Perl version. The 5.28 document also lists fixes for several regular-expression and Windows environment-buffer vulnerabilities. Treat those as reasons to keep Perl patched, not as a reason to copy old version-specific build settings into a current package.

Done means

  • You recorded the interpreter version and confirmed which Perl release the guide describes.
  • The use v5.28 feature check passes, including state initialisation and explicit bitwise operators.
  • The script-run expression compiles, and you understand that it is experimental and application-specific.
  • The disposable -i test leaves both the edited file and its backup with the expected contents.
  • You searched upgrade-sensitive syntax and will run the real test suite before changing production files.