|more useful options|
Re: Handling Mac, Unix, Win/DOS newlines at readtime...by Flexx (Pilgrim)
|on Sep 16, 2002 at 09:09 UTC||Need Help??|
I'd think that using \r or \n in this script should be considered harmful. If you'd really want to be portable (which might not be the case) you should exclusively use \015 and \012 to match DOS/Linux/Mac CRLF's
Imagine this script to be run on some box using EBCDIC (I know this is most probably a hypothetic assumtion but, oh well, I just want to demonstrate something here...)
Read perlebcdic. I has an example saying:
Uh-Oh... That means if you'd split on an EBCDIC system's perl on \n, you'd actually split on '%' or NAK respectively.
You really want to use HTML::Parser (or even XML::Parser) to parse your input. At least do something like this (untested):
Whatever approach you'll choose, input normalization is not really a trivial problem...