|XP is just a number|
splitting on win32 linefeeds aka pass the crackpipe!by mr.dunstan (Monk)
|on Feb 14, 2002 at 01:42 UTC||Need Help??|
mr.dunstan has asked for the wisdom of the Perl Monks concerning the following question:
Hi - I'm 3 hours into this problem and I'm getting bummed out. Here's what I'm trying to do:
I have a cgi script I'm working on that allows me to upload a file into the perl script using a file input element and CGI.pm and a multipart form. No problem there, been there done that.
The problem is - once I have read the file contents into memory, I want to parse it line-by-line, hopefully by reading each line into an array (this is fixed-width data mixed in with some unstructured data, thanks silly vendor, and the document itself is only vaguely structured, but if I can read it line by line I'm good to go.) The thing is - once I've read it into a scalar, the line feeds disappear BUT if I read it out to a file on the local filesystem (not an option in production BTW), the line feeds are there?!
I've tried split on the line feeds but they're not there - see example below. Way confused. Anyway here's what I'm trying to do, in short. Yes I am using strict ...
I'm sure there's a better way, like reading the file into an array somehow. Oh perlmonks deliver me from this pain!!!!