Hi,
I don't speak format, perlform is short on examples
so I haven't figured out the answer to your question but I kinda like this
#!/usr/bin/perl --
use strict;
use warnings;
Main( @ARGV );
exit( 0 );
{
use constant +{ qw{ TYPE 0 NAME 1 ACTION 2 } };
## to undefine globals TYPE/NAME/ACTION outside of this block
use namespace::clean;
format OFG =
@<<<<<<<< @<<<<<<<<<<<<<<<<<<<< @<<<<<<
$_[TYPE], $_[NAME], $_[ACTION]
.
}
format THREECHARFORMAT =
^<<~~
$_[0]
.
sub fwThree {
return formatWrite( *STDOUT, "::THREECHARFORMAT", @_ );
}
sub formatWrite {
use IO::Handle;
my $handle = shift;
my $format = shift;
local @_ = @_;
$handle->format_name( $format );
write $handle;
}
sub Main {
fwThree("foobar");
formatWrite( *STDOUT, "::OFG", qw/ TYPE NAME ACTION / );
formatWrite( *STDERR, "::OFG", TYPE(), NAME(), ACTION() );
}
__END__
$ perl format.fill.overflow.11113982.pl
foo
bar
TYPE NAME ACTION
Undefined subroutine &main::TYPE called at format.fill.overflow.111139
+82.pl line 56.
I would abandon format, switch to Perl6::Form, cause format appears to be one ignored wart (see Perl format line breaking, $FORMAT_LINE_BREAK_CHARACTERS apparently ignored )
Perl6::Form comes with demos, not sure if one fits what you want
https://metacpan.org/source/DCONWAY/Perl6-Form-0.090/demo/demo_break_word.pl
https://metacpan.org/source/DCONWAY/Perl6-Form-0.090/demo/demo_break_width.pl
https://metacpan.org/source/DCONWAY/Perl6-Form-0.090/demo/demo_overflowed_columns.pl