use warnings; use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Word'; my $MYDOC = "C:\\Document and Settings\\mhd\\My Documents"; my $DOCFILE = "$MYDOC\\work\\apifunc.doc"; #open STDERR, ">errlog.txt"; my $document = Win32::OLE->GetObject($DOCFILE) or die("Unable to open document ", Win32::OLE->LastError()); #close STDERR; open FH,">functionList.cpp"; my $pat='\d{1,2}\.(\s)+(V|v)oid'; my $paragraphs = $document->Paragraphs(); my $par; my $enumerate = new Win32::OLE::Enum($paragraphs); while(defined($par = $enumerate->Next())){ if($par =~ m|$pat| ){ print FH; } } close (FH) or die "can't close :$! \n"; #### Unable to open document Win32::OLE(0.1709) error 0x800401ea: "Moniker cannot open file" after character 0 in "C:\Document and Settings\mhd\My Documents\work\apifunc.doc" at extractfunctionName.pl line 13.