-
-
16 Apr 2014 18:33:32 UTC
- Distribution: Embperl
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (9)
- Testers (66 / 28 / 0)
- Kwalitee
- License: unknown
- Activity
24 month- Tools
- Download (768.94KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Gerald Richter <richter at embperl dot org>
- Dependencies
- File::Spec
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- NAME
- SYNOPSIS
- DESCRIPTION
- Example for generating a serial letter from a database
- Methods
- Author
- See Also
NAME
Embperl::Syntax::RTF - define syntax for RTF files
SYNOPSIS
DESCRIPTION
Class derived from Embperl::Syntax to define the syntax for RTF files. RTF files can be read and written by various word processing programs. This allows you to create dynamic wordprocessing documents or let process serial letters thru Embperl.
Currently Embperl regocnices the fields
DOCVARIABLE
,MERGEFIELD
andNEXT
. Variablenames are resolved as hash keys to $param[0] e.g.foo.bar
referes to$param[0]{foo}{bar}
, the@param
Array can by set via theparam
parameter of theExecute
function.NEXT
moves to the next element of the @param array. If the end of the document is reached, Embperl repeats the document until all element of @param are processed. This can for example be use to tie a database table to @param and generate a serial letter.NOTE: Extenting this syntax to support full Embperl support (like embedding Perl into RTF file is planned, but not implemented yet)
Example for generating a serial letter from a database
use DBIx::Recordset ; use Embperl ; *set = DBIx::Recordset -> Search({'!DataSource' => $db, '!Table' => 'address', '!WriteMode' => 0}) ; die DBIx::Recordset -> LastError if (DBIx::Recordset -> LastError) ; Embperl::Execute ({'inputfile' => 'address.rtf', param => \@set, syntax => 'RTF'}) ; # if your database table contains fields 'name' and 'street' you can now simply insert a # fields call 'name' and 'street' in your RTF file and Embperl will repeat the document # until all records are outputed
Methods
Embperl::Syntax::RTF defines the following methods:
Embperl::Syntax::RTF -> new / $self -> new
Create a new syntax class. This method should only be called inside a constructor of a derived class.
AddRTFCmd ($cmdname, $procinfo)
Add a new RTF command with name
$cmdname
and use processor info from$procinfo
. See Embperl::Syntax for a definition of procinfo.AddRTFCmdWithEnd ($cmdname, $endname, $procinfo)
Add a new RTF command with name
$cmdname
and use processor info from$procinfo
. Addtionaly specify that a matching$endname
RTF command must be found to end the block, that is started by this RTF command. See Embperl::Syntax for a definition of procinfo.AddRTFCmdBlock ($cmdname, $endname, $procinfostart, $procinfoend)
Add a new RTF command with name
$cmdname
and and a second RTF command$endname
which ends the block that is started by$cmdname
. Use processor info from$procinfo
. See Embperl::Syntax for a definition of procinfo.Author
G. Richter (richter at embperl dot org)
See Also
Embperl::Syntax
Module Install Instructions
To install Embperl, copy and paste the appropriate command in to your terminal.
cpanm Embperl
perl -MCPAN -e shell install Embperl
For more information on module installation, please visit the detailed CPAN module installation guide.