RTF::Lexer - Rich Text Format (RTF) lexical analyzer.
use RTF::Lexer qw(:all); my $parser = RTF::Lexer->new(in => 'text.rtf'); my $token; do { $token = $parser->get_token(); } until $parser->is_stop_token($token);
RTF::Lexer is a low-level RTF format lexical analyzer. It splits the input stream into separate tokens, which can be handled by other high-level modules.
The constructor. Accepts the only argument in which must be an input file handle or a file name. In the latter case if there is a failure while opening the file method new throws an exception. By default the input is read from STDIN.
in
new
STDIN
Returns the next token from the input stream. The token is a reference to an array those first element is a numeric id of the token type. The second element is a string representation of the token. The third element may exists only if the token is a control word and represents the numerical parameter of this control word.
The following token types are recognized by RTF::Lexer, that are declared as constants in this module:
Control word (eg. \rtf1, \trowd).
\rtf1
\trowd
Control symbol, mentioned in RTF Specification version 1.7.
Unknown control symbol (i.e. not mentioned in RTF Specification).
Plain text.
Start of group ({).
{
End of group (}).
}
End of destination group (} that turns off destination mode).
Data in hexadecimal format that follows \' control symbol.
\'
End of binary data block (started by \bin control word).
\bin
Symbol which is not a hexadecimal digit found where ENHEX token expected.
Normal end of input stream.
Unexpected end of input stream.
End of group that does not match any start of group.
These constants are not exported by default. Any of them may be exported by request. All of them may be exported by the use of :all export tag.
:all
Pushes back token $token so the next call to get_token will return it.
$token
get_token
Turns on the destination mode, i.e. all tokens will be ignored until the end of current group.
RTF::Tokenizer, Rich Text Format (RTF) Specification.
It is impossible to have more then one RTF::Lexer objects in a single process.
Vadim O. Ustiansky <ustiansky@cpan.org>
EOT
To install RTF::HTMLConverter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RTF::HTMLConverter
CPAN shell
perl -MCPAN -e shell install RTF::HTMLConverter
For more information on module installation, please visit the detailed CPAN module installation guide.