package OOXMLSimple; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); use XML::Simple; use base 'Exporter'; @EXPORT = qw/parse_tables/; sub parse_tables { my $file = shift; my $zip = Archive::Zip->new(); die "Can't open $file" unless $zip->read( $file ) == AZ_OK; my $content = $zip->contents('content.xml'); my %tables = map {$_->{'table:name'} => [ map{ [ map { $_->{'text:p'} } @$_ ] } map {$_->{'table:table-cell'} } @{ $_->{'table:table-row'}} ] } grep {ref $_->{'table:table-row'} eq 'ARRAY' } @{ XMLin($content)->{'office:body'}->{'table:table'} }; return \%tables; } 1;