Menu ▾ ▴

#60 w whitespace escape warning with Perl 5.44

v1.0 (example)
closed-fixed
None
5
2026-10-07
2026-09-22
Sam James
No

With Perl 5.44, a warning gets printed when running kpcli:

$ kpcli
Possible attempt to escape whitespace in qw() list at /usr/bin/kpcli line 1641 (#1)
    (W qw) qw() lists contain items separated by whitespace; contrary to
    what some might expect, backslash characters cannot be used to "protect"
    whitespace from being split, but are instead treated as literal data.
    (You may have used different delimiters than the parentheses shown here;
    braces are also frequently used.)

    You probably wrote something like this:

        @list = qw(
            a\ string
            another
        );

    expecting to get a two element list containing the strings 'a string'
    and 'another'.  Instead the list will hold three elements: 'a\'
    (with a literal backslash), 'string' and 'another'.

    If you really want whitespace in your strings, build your list the
    old-fashioned way, with quotes and commas:

        @list = ( 'a string', 'another' );

    Note that this warnings is only emitted when the backslash is followed
    by actual whitespace (that qw splits on).

Possible attempt to escape whitespace in qw() list at /usr/bin/kpcli line 1769 (#1)

KeePass CLI (kpcli) v4.1.3 is ready for operation.
Type 'help' for a description of available commands.
Type 'help <command>' for details on individual commands.

kpcli:/>

Discussion

  • Lester Hightower

    • status: open --> closed-fixed
    • assigned_to: Lester Hightower
     
  • Lester Hightower

    Thanks for the bug report.

    This is due to a (really dumb, IMO) change in 5.44 that now throws this stupid warning on Perl code that is and has been valid for decades. In kpcli's case, this line is the trigger and it is found in two places in the code:

      my @busy_chars = qw(\ | / -); my $i=0; my $in=10;
    

    This is how it will be fixed in the next release: https://sourceforge.net/p/kpcli/code/75/tree/trunk/kpcli-DEVELOPMENT.pl?diff=6570cda74363ae34c51814f1:74&diformat=sidebyside

    hightowe@eden ~/src/perl/kpcli-code/trunk $ svn diff --diff-cmd diff -x "--normal"
    Index: kpcli-DEVELOPMENT.pl
    ===================================================================
    200a201,202
    > my @BUSY_CHARS = qw(\\ | / -); # Unfortunate workaround to Perl 5.44+ stupidity
    > 
    1669c1671
    <   my @busy_chars = qw(\ | / -); my $i=0; my $in=10;
    ---
    >   my $i=0; my $in=10;
    1671c1673
    <     printf "%s\r", $busy_chars[int($i/$in)%($#busy_chars+1)] if (!($i++ % $in));
    ---
    >     printf "%s\r", $BUSY_CHARS[int($i/$in)%($#BUSY_CHARS+1)] if (!($i++ % $in));
    1797c1799
    <   my @busy_chars = qw(\ | / -); my $i=0; my $in=100;
    ---
    >   my $i=0; my $in=100;
    1799c1801
    <     printf "%s\r", $busy_chars[int($i/$in)%($#busy_chars+1)] if (!($i++ % $in));
    ---
    >     printf "%s\r", $BUSY_CHARS[int($i/$in)%($#BUSY_CHARS+1)] if (!($i++ % $in));
    10388c10390
    < 
    ---
    >                   - Perl v5.44+ qw warning fix per SourceForge bug #60.
    

    That is overkill since adding a "\" at the two "@busy_chars =" lines would fix it, but I am a fan of consolidating and documenting stuff like this...

     

Log in to post a comment.