superpete has asked for the wisdom of the Perl Monks concerning the following question:

In my quest to make my code support completely arbitrary filenames, I think i've succeeded.

But I have uncovered a new issue. Whenever a "-X" test returns a negative result, and the filename happens to have a newline in it (newlines are valid in unix filenames), perl issues a "Unsuccessful stat on filename containing newline" warning. (if we're running perl -w)

According to the perldiag manpage, perl thinks I forgot to chomp my filename. But what if the filename really has a newline in it?

-e "$dir/foo" or mkdir "$dir/foo"

If $dir happens to have a newline in it, the code results in a warning :-(

What to do? Is there a way to suppress that one specific warning?