use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my $path = 'E:/MASAV/DOC/'; my $input = 'input.txt'; my $in_file = $path . $input; my $counter = 4534; my $My_Word = Win32::OLE->new('Word.Application') or die "Problem with MS-WORD"; open (INPUTFILE, "<$in_file")|| die "Can not open $in_file\n"; while() { chomp $_; $counter++; my $docx_name = $counter.".docx"; $My_Word->{'Visible'} = 0; $My_Word->{DisplayAlerts} = 0; my $My_Save = $My_Word->ActiveDocument->SaveAs( {FileName => $docx_name, FileFormat => wdFormatDocument}); $My_Word->{ActiveDocument}->Close; } $My_Word->Quit;