I had no problem using stat on a file path containing backslashes and apostrophes. (Just to be clear, that doesn't mean that those characters aren't indeed the problem in your environment.)
One possible explanation for your problem above would be a simple "\r" at the end of the string after chomp was called. Any number of other "invisible" characters could also be to blame. At least output the length of the string as well. Adding surrounding punctuation to the output can help for some "invisible" characters. Using something like Data::Dumper (if you set the option to use double quotes instead of single quotes) or the Perl debugger (see the "x" command) can make such problems obvious.
And, yes, even if you are using a native Windows build of Perl that by default replaces "\r\n" with "\n" when reading, it would replace "\r\r\n" (for example) with "\r\n" and chomp would replace that with just "\r", which would cause the behavior you showed.
|