On Apr 21, 2010, at 8:04 PM, John E. Malmberg wrote:

martin.zin...@deutsche-boerse.com wrote:
Hello Colleagues,
I am currently trying to drag our development team kicking and screaming into the century of the fruitbat, but what looks like a bug in 5.10.1 and 5.12.0 is a stumbling block.
Problem description:
If you open a text file with Carriage return carriage control for output (based off an existing file) and populate the new file with longer records, at some point gratuitous line breaks are added to the file. This does not happen with either Perl 5.8.0 on Alpha, nor Perl 5.8.5 on Itanium (in that case the hp build). It does happen with both 5.10.1 and 5.12.0 on Itanium.

Thanks for the report, and especially for the concise reproducer. The first thing that springs to mind in this area regarding changes between 5.8.x and 5.10.x is the default PerlIO behavior. I don't remember exactly when it changed, and the change might not have been documented as well as it should have been since it wouldn't have made any difference with stream-oriented files, but basically it's now doing the unixio write() rather than the stdio fwrite() by default. It's not especially surprising that fwrite() is a bit more simpatico with record-oriented files than is write().

There are umpteen different ways to get the old behavior or accommodate the new behavior. There is a configure-time option to disable perlio, which is equivalent to doing:

$ define PERLIO "stdio"

at run-time.  Or you can add:

use open OUT => ':stdio';

before the open statement (<http://perldoc.perl.org/open.html>).

Or push the stdio layer as part of the open statement itself (<http://perldoc.perl.org/functions/open.html >):

--- mztest.com;-0       2010-04-21 19:33:50 -0500
+++ mztest.com  2010-04-21 22:30:11 -0500
@@ -23,7 +23,7 @@ $  ENDIF
 $!
 $  perl -w SYS$INPUT: 'p1'
 $  DECK
-open( TXT, ">test.lis");
+open TXT, '>:stdio', 'test.lis';

 for ($i=0;$i<=120;$i++){
     printf( TXT
[end]

Or you can force the file to be a stream file using vmssysopen.

Or you can experiment with syswrite or vmssyswrite instead of print so that you control the size of the record you are writing.

Or you could (possibly, depending on the real-world problem behind the reproducer) create the existing file as STREAM_LF (or convert it to such) before Perl ever sees it and inherits its default record attributes.

The issue is that the pipe emulation code in perl adds extra new- lines to output from subprocesses.

Since there is no piping in Martin's reproducer, I'd say there's about a 0% chance pipes have anything to do with it.

The size of the mailbox buffer may have something to do with when the new-line is added. It may be that something changed there. In PERLVMS.POD, it documents that PERL_MBX_SIZE controls this with a default of 512 bytes.


That's the most common cause of newlines where you don't want them, but not in this case. BTW, the default is now 8192 bytes in 5.12.0.

________________________________________
Craig A. Berry
mailto:craigbe...@mac.com

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

Reply via email to