in reply to How do I get rid of the cr/lf

Also, to venture outside Perl for a moment...if you simply call dos2unix on your input files prior to processing them, the script won't have to deal with it at all.