in reply to Problems with chomp

I am having problems with the chomp command

Not true. You proved yourself it's not a problem with chomp by using s/// and still having the same problem. chomp only removes from the end of string, and only removes the string found in $/ ("\n" by default).

I suspect that your string might have characters your terminal interprets as control characters, causing some or all of the line to be overwritten. Specifically, the "a" is being overwritten by the following space:

print "DEBUG: After chomp: $summaryFile \n"; ^ |

The "a" wasn't being overwritten before the chomp because the newline was printing the space on a new line.

I suspect you actually get the following output:

DEBUG: Before chomp: /warp/pub/testbot2/users/rehmanz/2009Aug23_151934 +/essw/bats /autobats/summary.log DEBUG: After chomp: /warp/pub/testbot2/users/rehmanz/2009Aug23_151934/ +essw/bats/ utobats/summary.log

(Boooo! Saying it adds a space in the middle of the output is very inaccurate.)

This can be obtained on an 80-col terminal with the following input:

"/warp/pub/testbot2/users/rehmanz/2009Aug23_151934/essw/bats/autobats/ +summary.log\r\n"

Your file has DOS line endings, but you're not using the :crlf PerlIO layer. You should convert your file, but using the following should do the trick (and trims trailing whitespace as a bonus):

s/\s+\z//;

If that's not the case, check what your string actually is by piping the output through od -c.

Update: Added everything after "I suspect" except for the last paragraph.