use strict; use warnings; require Text::Extract::Word; Text::Extract::Word->import( qw(get_all_text) ); my $InputFileReadable ='Input.doc'; my $content = get_all_text($InputFileReadable); #detecting structure my ($header, $body)= split /(\a)\1+/, $content; my $NrSeparators = () = $header =~ /\a/g; my @cells = split(/\a/, $content); my $count=0; open(FH, '>', "Output.txt") or die $!; foreach (@cells){ $count++; print FH $_; if ($count eq $NrSeparators+2){ print FH "\n"; }else{ print FH "\t"; } $count = 0 if $count eq $NrSeparators+2; } close(FH);