Hello

The following code reads the values of variables stored in several separate text files.
open PL, 'pvclength.txt' or die "Cant open file"; pvc_l=<PL>; open GIL, 'gilength.txt'or die "Cant open file"; $gipipe_l=<GIL>; open QGBS, 'qgibendsocket.txt' or die "Cant open file"; $gibend_sck_q=<QGBS>;
When writing these values and other computed values to a report file(.doc) using the code below:
printf EH "\n Item"; printf EH "\n No Descr. Qty Unit Rate Comp. + Party"; printf EH "\n 70 Pvc 4sqmm $pvc_l MTR 35.14 0.00 + $pvc_a"; printf EH "\n 71 Gi Pipe 25mm $gipipe_l MTR 94.93 0.00 + $gipipe_a\n"; printf EH "\n 73 Gi Bend $gibend_sck_q NO 50.00 0.00 + $gibend_sck_a\n"; printf EH "\n &Socket25mm\n";
The expected output is:
Item No Descr. Qty Unit Rate Comp. Party 70 Pvc 4sqmm 2 MTR 35.14 0.00 70.28 71 Gi Pipe 25mm 3 MTR 94.93 0.00 284.79 73 Gi Bend 4 NO 50.00 0.00 200 &Socket25mm
But the output I get is this i.e. everything after the Qty figure appearing on the second line
Item No Descr. Qty Unit Rate Comp. Party 70 Pvc 4sqmm 2 MTR 35.14 0.00 70.28 71 Gi Pipe 25mm 3 MTR 94.93 0.00 284.79 73 Gi Bend 4 NO 50.00 0.00 200 &Socket25mm
How to get around this problem? I tried removing whitespace from the Qty variables for example $pvc_l but that did not work. Any advice would be appreciated. Thanks.

Update

The .txt files contain just a single value for example "pvclength.txt" just contains the value 2.

In reply to File write problem by perl_seeker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.