Re^4: Get record separator of a fileby davido (Archbishop)
|on Nov 14, 2012 at 00:08 UTC||Need Help??|
Now we're getting somewhere (I think). You should be able to take advantage of Perl's :crlf IO layer to handle the problem for you.
First, Tie::File seems to be "layers" unaware, which is fine, except that you'll have to open the file explicitly, and close it again when you're done, rather than letting Tie::File handle those operations. This gives you control over what layers are applied to the file handle.
The relevant explanation of ':crlf' from the POD is: " On read converts pairs of CR,LF to a single "\n" newline character. On write converts each "\n" to a CR,LF pair." Since this happens behind the scenes, it should play nice with Tie::File, but I would test on some copies of the files first to be sure.
Updated: Added weaken to eliminate a potential memory leak, since tie also holds a ref to its own object.