How to read line by line a CR-only file with Perl?
Posted
by Subb
on Stack Overflow
See other posts from Stack Overflow
or by Subb
Published on 2010-06-10T20:03:17Z
Indexed on
2010/06/10
20:12 UTC
Read the original article
Hit count: 292
Hi,
I'm trying to read a file which has only CR as line delimiter. I'm using Mac OS X and Perl v.5.8.8. This script should run on every platform, for every kind of line delimiter (CR, LF, CRLF).
My current code is the following :
open(FILE, "test.txt");
while($record = <FILE>){
print $record;
}
close(TEST);
This currently print only the last line (or worst). What is going on? Obvisously, I would like to not convert the file. Is it possible?
© Stack Overflow or respective owner