On 04/01/2012 14:02, Hamann, T.D. (Thomas) wrote:
Okay, some further testing using a family member's Windows XP PC and a fresh install of ActivePerl seems to have revealed the culprit: Changing s/\s+$//; to: s/(\s+$)(\n)/$2/; fixed the issue. Since the script worked fine until about 3 weeks ago and I copied the original code from http://www.perlmonks.org/?node_id=2258, I can only surmise that Microsoft must have changed the way Windows XP deals with newlines in a very recent update. Which they could have communicated with the outer world. :( (oh well, another reason to dislike Microsoft, I guess). Now for another question: How much code will this change break?
I'm afraid something else must have changed, as /\s+/ has always matched HT, LF, CR, FF, and space, so that line would always remove a trailing newline. In your eagerness to find fuel for your hatred for Microsoft you are forgetting that Perl normalizes all native file records so that they end with "\n" when they are read from the file. Such arbitrary nonsense impedes proper bug-fixing and has no place on this list - Microsoft is not a football team. The usual solution to your problem is to 'chomp' the line terminator from the end of the line before applying the edits, and then adding it back again on output. Precisely why you program has changed behaviour I cannot tell, but be assured that the code you show has always removed trailing newlines and the problem must lie elsewhere Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/