I have a script that works with data of a Word document and I use the OLE module for this. I have a problem when trying to read all the paragraphs and comparing each of them with a paragraph
One of the paragraphs is named "Introduction" and instead of "Introduction post" I get "postoduction". Apparently the 2nd print command starts printing on the same location and acts like the first print never took place.
I already took care of this problem by typing substr($text,0,-1). However, I'd like to know why $text acts like this, why substr solves this and if there are any more elegant ways to deal with this than taking a substr from it ?
Code:
my $paragraphs = $doc->ListParagraphs;
foreach my $paragraph (in $paragraphs) {
my $text = $paragraph->Range->Text;
print "$text"
print " post\n";
}
One of the paragraphs is named "Introduction" and instead of "Introduction post" I get "postoduction". Apparently the 2nd print command starts printing on the same location and acts like the first print never took place.
I already took care of this problem by typing substr($text,0,-1). However, I'd like to know why $text acts like this, why substr solves this and if there are any more elegant ways to deal with this than taking a substr from it ?