in reply to Dealing with files with differing line endings
A general solution is impossible. Any file can contain normal text characters that another OS would interpret as line separators. You may be able to assume that this will never happen with your data. Your idea of slurping the entire file (in binmode) into a string is probably the safest. Use anything you know about the file (line length, number of lines, words that only occur at the start or end of a line, etc) to determine which kind of file it is. Open the string as a memory file with the appropriate IO layer. You could then use the <> operator exactly as you normally would.
Bill
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Dealing with files with differing line endings
by Marshall (Canon) on Nov 06, 2021 at 23:20 UTC | |
by BillKSmith (Monsignor) on Nov 07, 2021 at 21:22 UTC | |
by Marshall (Canon) on Nov 11, 2021 at 21:19 UTC | |
by afoken (Canon) on Nov 12, 2021 at 13:54 UTC | |
by Marshall (Canon) on Nov 15, 2021 at 20:33 UTC | |
|
In Section
Seekers of Perl Wisdom