I have downloaded the following file: rawdata_2001.text
and I have the following perl code:
open TEXTFILE, "rawdata_2001.text";
while (<TEXTFILE>) {
print;
}
This however only prints the last line in the file. Any ideas why? Any feedback would be greatly appreciated.
The file is formatted with carriage returns only, so it’s being sucked in as one line. You should be able to set $/ to “\r” to get it to read line by line. You then should strip off the carriage return with chomp, and be sure to print a new line after the string.