karlberry has asked for the wisdom of the Perl Monks concerning the following question:

I'm using the fill mode of formats (how 1970s, I know). If a source word is longer than the format line, it is forcibly broken at the format length. Can this be changed, so that it is output in its entirety? For example:
my $str="foobar";
format threecharformat =
^<<~~
$str
.

my $fd = STDOUT;
select((select($fd),$~ = "threecharformat")[0]);
write $fd;  # use that format
The output is two lines:
foo
bar
but I want just one line: foobar. Is it possible?

I could find nothing in perlform or perlfaq* or online about controlling the behavior when the source word overflows the format. I tried to look at the source but am far too much of a novice at Perl internals to get anywhere. (I could not even discern where formats were executed, after KEY_format, etc., were parsed.)

In the actual application, the source text contains long urls, which I don't want to be broken. In my case, it is not a stopper that the result would not then match the format.

I yield to your wisdom. Thanks. --karl@freefriends.org

  • Comment on disabling forced line break with format fill mode and long source word

Replies are listed 'Best First'.
Re: disabling forced line break with format fill mode and long source word (perlform Perl6::Form)
by Anonymous Monk on Mar 08, 2020 at 23:46 UTC