A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Perl/perl5/issues/18293 below:

stacked filetest ops stat unexpected “filename containing newline” · Issue #18293 · Perl/perl5 · GitHub

Module: core

Description

The following MWE script unexpectedly outputs a warning about an “unsuccessful stat on filename containing newline”:

#!/usr/bin/perl
use 5.014;
use warnings;
use HTTP::Tiny;

HTTP::Tiny->new->head("https://www.perl.org/");
if ('a' =~ /^(.)$/) {
    if (-f -r $1) {
        say "a";
    }
}

A workaround is to replace -f -r $1 with -r $1 && -f _. This is in contradiction to the documentation in man perlfunc, which states that the former is just “a form of purely syntactic sugar” for the latter.

Steps to Reproduce

Run the above script on Ubuntu Linux (e.g., 20.04).

Actual behavior

$ ./bug.pl 
Unsuccessful stat on filename containing newline at ./bug.pl line 8.

Expected behavior

$ ./bug.pl 
$ touch a
$ ./bug.pl 
a

Perl should try to stat the filename a instead of any “filename containing newline”,
and output a if and only if file a exists and is readable.

Perl configuration

I encountered this behaviour on both Perl 5.30.0 as included in Ubuntu Linux 20.04 (x86_64), as well as Perl 5.22.1 as included in Ubuntu Linux 16.04 (x86_64).


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4