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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |