Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: stat on file name containing single quotes

by perlpipe (Acolyte)
on Jul 31, 2015 at 15:06 UTC ( [id://1137016]=note: print w/replies, xml ) Need Help??


in reply to Re^2: stat on file name containing single quotes
in thread stat on file name containing single quotes

Note that the "chomp" and the "say" don't seem to have a problem with the variable $fn containing a string that has single quotes and backslashes in it. So I was expecting "stat" to not have a problem. Obviously I was wrong.
  • Comment on Re^3: stat on file name containing single quotes

Replies are listed 'Best First'.
Re^4: stat on file name containing single quotes (\r?)
by tye (Sage) on Jul 31, 2015 at 15:43 UTC

    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.

    - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1137016]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-23 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found