I have a text file that is formatted oddly... I'm running in Windows environment and need an extremely simple 4 or 5 lines of Perl to fix this. The solution must be Perl and must run on Windows as it will integrated into a much larger Perl script. The file at the end of the first line terminates with 0d 0d 0a 0d 0d 0a or LF (linefeed) LF CR (carriage return) LF LF CR This structure causes me problems. I want the LF LF CR to be replaced with a standard Windows CR LF... I have tried simple s/\n//g type stuff and i can't get it to work. Have also tried opening the file in binary mode - again - no luck... Send me a PM if you can do this - you must be able to do it IMMEDIATELY - this is not a get back to me later project... Send me your email address in the PM so I can email you the sample file. I will PayPal $10 immediately upon confirmation that the code works. Thanks
Try { undef local $/; open(F, '+<file.txt') || die $!; my $str = <F>; $str =~ s/\n\n\r/\r\n/g; truncate F, length $str; sysseek F, 0, 0; syswrite F, $str; close F; } Code (markup):