This question doesn't concern a problem with Perl itself, but I wonder
whether anybody else has faced or solved the problem.

We have Perl scripts that parse the text output of some of our C++
programs.  We recently switched to using the ANSI-standard class library,
including the new stream classes.  With the new library, the iostream I/O
and standard I/O are synchronized, which seems like a nice feature, because
I believe it will mix the outputs via cout and via printf in the right
order.  The problem is that on VMS, where files have records, each item put
out to cout is now in a separate record, which did not used to happen.  For
example, with the following code:

cout << "aaa";
cout << "bbbb";
cout << "ccccc" << endl;

With the old Compaq C++ class library, that code would produce one record
in stdout, with "aaabbbbccccc" in it.

Now we get four records, one for each of the three strings and an empty one
for the endl.  It looks correct on the terminal, showing one line of 12
characters, but the Perl script that receives the output sees the separate
records and can't really tell where the program intended the line to end.
We can't reliably use the empty record to signal the end of line because
the following code produces only three records:

cout << "aaa";
cout << "bbbb";
cout << "ccccc\n";

We can use the following line to revert to the old behavior, but I'd like
to be able to work with the new stuff and still maintain portability across
VMS, UNIX and Windows.  I believe that UNIX and Windows, with their streams
of bytes, don't have the problem, although I haven't probed as deeply
there.

ios_base::sync_with_stdio( false );

--Travis Craig

ALSTOM's T&D Energy Automation & Information Business
Bellevue, WA

CONFIDENTIALITY: This e-mail and any attachments are confidential and may
be privileged. If you are NOT a named recipient: please notify the sender
immediately, do NOT disclose the contents to another person, do NOT use the
contents for any purpose, do NOT store or copy the information in any
medium.

CONFIDENTIALITE : Ce message et les �ventuelles pi�ces attach�es sont
confidentiels. Si vous n'�tes pas dans la liste des destinataires, veuillez
informer l'exp�diteur imm�diatement et ne pas divulguer le contenu � une
tierce personne, ne pas l'utiliser pour quelque raison que ce soit, ne pas
stocker ou copier l'information qu'il contient sur un quelconque support.



Reply via email to