At 10.22 -0500 1999.11.19, Ben_Tilly@trepp.com wrote: >I have just talked to one too many people who have been bitten by this... > >Is there any possibility of having Perl's chomp() command be modified to >recognize \n, \r, and \r\n as line-endings to chomp? A source of nasty >confusion for people working in a cross-platform environment is when >identical Perl scripts give very different results on the same exact file >depending on whether you are running under *nix or Windows. (Particularly >an issue with Samba because people wind up reading under one system files >created under the other.) > >Yes, the current behaviour works as documented. But it leads to code not >doing what people expect, and in many cases a confused person will spend >several hours confused... Well, these sam people will also have a problem with readline and <>. And I certainly don't want behavior where readline and chomp treat different things as record separators. I would like to see, perhaps, a regex IRS, so you could do: $/ = qr/(?:\015\012?|\012)/; or whatever. Of course, that is flawed, in that it won't catch the special (usually broken) case of a file having CR, LF, or CRLF mixed in the same file. Oh well. Another solution would involve per-filehandle IRS, where you could call a function (say, textmode()) that would inspect the filehandle and set the IRS appropriately for that filehandle. This is more subject to failure for sockets, though, because it would involve reading, looking at the data, and then seeking back to the beginning. I have a prototype of something that tied filehandles to do this, but it fails with sockets, and doesn't do anything for chomp() anyway (and didn't work great anyway because of some flaws in tied filehandles and prototypes ... I was using 5.004, I don't know if the flaws have been fixed or whatnot). -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])Thread Previous | Thread Next