in reply to chomp ^M ?

I prefer to do it like this:
s/[\r\n]+$//;
This will take care of any line-end, might it be DOS (CR LF), *NIX (LF) or Mac (CR).