Yes, that approach would work. When I considered that idea, I was thinking of opening the file in bin mode. Read a block of data. Use
substr index to find first <CR> and then run
substr index to find first <LF>, from those index numbers I could figure out what kind of file it was. I'd probably close file and report back the line ending value from a "discover_line_ending sub". And have main program re-open the file in text mode with correct input line separator. BTW,
substrindex is a very fast critter because it is "stupid" - searching to the end of the input block with no search value found is "fast".
Another idea I considered was to slurp in the whole file as binary - the max size of this file is small enough to do that. Then use split to do my own line division. The input line separator cannot be a regex, but split can use a regex.
As I mention in my now updated question post, I found out where this "weird duck" file came from. There is no need for me to solve this tricky problem at this time. Users do the darndest things! The "hey, don't do that!" answer appears to meet all of my requirements and user is fine with that "solution". Not every complicated problem requires an actual implementation. At some point in the future, I may have to actually implement a solution for this problem and what I've learned in this thread will be helpful. I think there are also fine points in this thread that could be useful for other problems. In my opinion, you can never "know too much" about Perl.