RandomWalk has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks, I'm building Perl 5.8.5 under Linux on a SunBlade 100. "make" is ok, but "make test" fails at op/write.t, and then just the first 3 tests. Every other test is ok. The first three tests test "format"; the first goes thus:
format OUT = the quick brown @<< $fox jumped @* $multiline ^<<<<<<<<< $foo ^<<<<<<<<< $foo ^<<<<<<... $foo now @<<the@>>>> for all@|||||men to come @<<<< { 'i' . 's', "time\n", $good, 'to' } . open(OUT, '>Op_write.tmp') || die "Can't create Op_write.tmp"; END { 1 while unlink 'Op_write.tmp' }$good = 'good'; $multiline = "forescore\nand\nseven years\n"; $foo = 'when in the course of human events it becomes necessary'; write(OUT); close OUT or die "Could not close: $!"; $right = "the quick brown fox jumped forescore and seven years when in the course of huma... now is the time for all good men to come to\n"; if (cat('Op_write.tmp') eq $right) { print "ok 1\n"; 1 while unlink 'Op_write.tmp'; } else { print "not ok 1\n"; }
I'm supposed to get $right, and here is what I get:
the quick brown fox
jumped
forescore
and
seven years
when in
the course
of huma...
now is thetime  for all good men to come to

The space that was to preceed time now follows it. I don't understand what happened to the newline, but it does appear that the output I got did mess up the padding. What do you think?

20040810 Edit by ysth: change title from: make test failure

Replies are listed 'Best First'.
Re: perl-5.8.5 op/write.t fails
by Prior Nacre V (Hermit) on Aug 06, 2004 at 21:46 UTC

    You have set the field where 'time' goes as 4 characters, right-justified BUT you pass it a string of 5 characters: 't', 'i', 'm', 'e', and "\n".

    Set this field to '@>>>>>' and you should be right.

    Regards,

    PN5

      Ah, I see more clearly now.

      From perldoc perlform: "For a regular field, the value (up to the first newline) is taken and printed according to the selected justification, truncating excess characters."

      So it seems to me now that 5.8.5 is mishandling newlines in fields to be formatted. Yes?

      How important could this be? I guess I should look at the other two tests before I force "make install"...

        Actually, hold that thought - something is definitely screwy here. I've checked 5.6 and 5.8 doco - they concur - so it would appear that v5.8.5 is getting it wrong (as you say) but you shouldn't need to change anything to make this work (as I suggested).

        I have v5.6.1 and v5.8.2 here - I'll run some tests and check this out.

        Update
        The code you posted works correctly (i.e. prints "... is the time for ...") on both those versions. Looking like a v5.8.5 bug. See if you can find someone with 5.8.5 installed - Any takers monks?

        Regards,

        PN5