Hello everybody,

In the example script below, I'd expect to see 3 lines of text appearing
when I use the 'write' command but I only see the first two (123 followed
by 456).

I know that as much as possible is read from the variable before filling
and printing a field (as many words or as many characters as possible?).

In this example, this is the behaviour I deduced:
1. Read 10 characters (the width of the field): "123\r\n456\r\n"
2. Print "123\r\n" but leave the rest in the variable
3. Read 10 characters: "456\r\n789\r\n"
4. Print "456\r\n" (but leave the rest in the variable?)
5. Since the variable was emptied in step 3, we're finished (!!!??) and
   there's nothing left to do (and therefore '789' is not printed).

If I add one '\n' to the end of the string then the line '789' appears as
well.
Basically, playing with different lengths of the field and sizes of the
lines in the variable, the last lines (i.e. a series of characters ending
with '\r\n') are 'lost' if they are small enough to fit together in the last
'read-pass'.



My questions:

1) Is this behaviour correct? I'm using perl v5.6.0, built for i386-linux.

2) If this is not a bug, how can I ensure that all the lines appear
   when executing 'write'?

3) A bit off the toping, but is there a way to use '~~' and still have
   the lines printed from the very first column?



===============================================================
#!/usr/bin/perl

$test_body = "123\r\n456\r\n789\r\n";
print $test_body;

write;

format STDOUT =

test format

~~^<<<<<<<<<
$test_body
.

===============================================================
This script outputs:

123
456
789

test format

  123
  456
===============================================================
------------------------------------------------------------
Philippe Brodier-Yourstone                 [EMAIL PROTECTED]
Nagravision                             http://www.nagra.com
Route de Genève, 22                   Tel: +41 (0)21 7320625
CH-1033 Cheseaux / Switzerland        Fax: +41 (0)21 7320300
------------------------------------------------------------

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to