bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monasterians,
I've done this before, but not often. Normally, this...
open (FILE, "somefile.txt") or die; my @records = <FILE>; close(FILE);
OR
my @records; open (FILE, "somefile.txt") or die; while (<FILE>) { push @records, $_; } close(FILE);
...renders a nice array of one line per element.
Today, the above placed the entire file of 10 lines into one element. I hex-dumped the file and noted the line endings were 0D, but I'm not sure what they should be.
To get it to work, I had to do this...
my @records = split(/\r/,$records);
Has this something to do with how the text file was saved? Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading in a file not recognizing lines
by Fletch (Bishop) on May 21, 2006 at 23:19 UTC | |
by bradcathey (Prior) on May 22, 2006 at 11:24 UTC | |
|
Re: Reading in a file not recognizing lines
by bobf (Monsignor) on May 22, 2006 at 02:32 UTC | |
|
Re: Reading in a file not recognizing lines
by ioannis (Abbot) on May 22, 2006 at 02:31 UTC | |
|
Re: Reading in a file not recognizing lines
by jesuashok (Curate) on May 22, 2006 at 02:47 UTC |