This is not a bug, and even cannot be called as undocumented feature. format is meant to handle report format, and in this case, the output did strictly follow the format you specified. Visually you got what you asked. It is the wrong expectation to have format work as an alternative version of sprintf.

It is not really that scary to make it work for you. You can just do something like:

use strict; use warnings; my ($field1, $field2); format = @<<<<@>>>@ $field1,$field2, 'x'; . $field1 = "Hello"; $field2 = " "; write; $field1 = "ab"; $field2 = "cd"; write;

The other side is mainframe right? On mainframe there is a tool to chop away certain columns of a fixed-length file (super easy). Just ask your mainframe guys to add one step in their JCL, before the step they use your data.

If your mainframe program is written in COBOL, simply change the copy file, which contains the definition of the file they expect from you. If the program is well designed, all you need to do it to change one copy book and recompile whole bunch of programs use that copy file. (This is not recommended, what I said in last paragraph is much better and much less risk.)

Mainframe is not scary at all.


In reply to Re: Format not adding to line when ending in spaces by pg
in thread Format not adding to line when ending in spaces by spudnic

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.