Perl parts in grofffiles are enclosed by two .Perl requests with different arguments, a starting and an
ending command.
StartingPerlmode
The starting Perlrequest can either be without arguments, or by a request that has the term start as its
only argument.
• .Perl
• .PerlstartEndingPerlmodewithoutstorage
A .Perl command line with an argument different from start finishes a running Perlpart. Of course, it
would be reasonable to add the argument stop; that's possible, but not necessary.
• .Perlstop
• .Perlother_than_start
The argument other_than_start can additionally be used as a groff string variable name for storage — see
next section.
EndingPerlmodewithstorage
A useful feature of gperl is to store one or more results from the Perlmode.
The output of a Perlpart can be got with backticks `...`.
This program collects all printing to STDOUT (normal standard output) by the Perl print program. This
pseudo-printing output can have several lines, due to printed line breaks with \n. By that, the output
of a Perl run should be stored into a Perl array, with a single line for each array member.
This Perl array output can be stored by gperl in either
groffstrings
by creating a groff command .dsgroffregister
by creating a groff command .rn
The storage modes can be determined by arguments of a final stopping .Perl command. Each argument .ds
changes the mode into groffstring and .nr changes the mode into groffregister for all following output
parts.
By default, all output is saved as strings, so .ds is not really needed before the first .nr command.
That suits to groff(7), because every output can be saved as groff string, but the registers can be very
restrictive.
In stringmode, gperl generates a groffstring storage line
.dsvar_namecontent
In registermode the following groff command is generated
.nrvar_namecontent
We present argument collections in the following. You can add as first argument for all stop. We omit
this additional element.
.Perl.dsvar_name
This will store 1 output line into the groff string named var_name by the automatically created
command
.dsvar_nameoutput.Perlvar_name
If var_name is different from start this is equivalent to the former command, because the string
mode is string with .ds command. default.
.Perlvar_name1var_name2
This will store 2 output lines into groff string names var_name1 and var_name2, because the
default mode .ds is active, such that no .ds argument is needed. Of course, this is equivalent to
.Perl.dsvar_name1var_name2
and
.Perl.dsvar_name1.dsvar_name2.Perl.nrvar_name1varname2
stores both variables as register variables. gperl generates
.nrvar_name1output_line1.nrvar_name2output_line2.Perl.nrvar_name1.dsvar_name2
stores the 1st argument as register and the second as string by
.nrvar_name1output_line1.dsvar_name2output_line2