in reply to How do I read an entire file into a string?
I'm reading a text file on Windows. I used the first solution on this page and then print the result in $string
:{ local $/ = undef; open FILE, "myfile" or die "Couldn't open file: $!"; binmode FILE; $string = <FILE>; close FILE; } print $string;
I noticed that the "end-of-line" for each line is changed from "0d 0a" to "0d 0d 0a"
I found that if I removed the "binmode FILE;" statement, "end-of-line" for each line is correctly printed as "0d 0a":
{ local $/ = undef; open FILE, "myfile" or die "Couldn't open file: $!"; $string = <FILE>; close FILE; } print $string;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Answer: How do I read an entire file into a string?
by BrowserUk (Patriarch) on Jun 15, 2016 at 00:22 UTC | |
by Discipulus (Canon) on Jun 15, 2016 at 07:41 UTC | |
by BrowserUk (Patriarch) on Jun 15, 2016 at 11:40 UTC | |
Re: Answer: How do I read an entire file into a string?
by Anonymous Monk on Jun 15, 2016 at 00:18 UTC |