http://www.perlmonks.org?node_id=1028731


in reply to parsing a table

Looking at an .rtf file and the spec and the available modules, the situation seems difficult. RTF::tokenizer seems helpful to reduce the complexity a bit. I have created a sample rtf file using MS Word which contains one table only and the following script gets me most contents of the table (and some more). I do not dare say whether this helps in your situation.

use strict; use warnings; use RTF::Tokenizer; my $rtf = RTF::Tokenizer->new( file => "A.rtf" ); my( $t, $a, $p ); my $on = 0; while( $t ne "eof" ) { ( $t, $a, $p ) = $rtf->get_token(); print "TYPE|$t|ARGUMENT|$a|PARAMETER|$p|\n" if $on and $t eq "text"; + $on = 1 if $t eq "control" and $a eq "ltrrow"; $on = 0 if $a eq "control" and $a eq "row"; }