if ( $file =~ /\.doc$/i ) { my $filename = $dir . "/docs/" . $file; $filename =~ s'/'\\' ; # invert slashes otherwise SaveAs cannot process the path correctly!!! my $savename = $dir . "/txt/" . $file . ".htm"; $savename =~ s/.doc//; print "Starting word\n"; my $Word = Win32::OLE->new( 'Word.Application', 'Quit' ); $Word->{Visible} = 0; my ($doc) = $Word->Documents->Open($filename) or die( "Unable to open document ", Win32::OLE->LastError() ); $doc->SaveAs( { FileName => $savename, FileFormat => wdFormatDOSTextLineBreaks } ); #FileFormat => wdFormatUnicodeText });#unicode support print "Closing document and Word\n"; $Word->ActiveDocument->Close(); $Word->Quit; $b++; }