rajkrishna89 has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use Win32::OLE; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Const 'Microsoft Word'; use Cwd; use File::Find; use Win32::OLE; use Win32::OLE::Enum; $Win32::OLE::Warn = 3; # die on errors. +.. my $out_file = 'output.txt'; open my $out_fh, '>', $out_file or die "Could not open file $out_file: +$!"; my $print_next = 0; #Globals our $Word; our $reviewchklists; my @scriptfiles; @scriptfiles=glob('*.doc'); foreach my $file (@scriptfiles) { my $var; my $filename = "D\:\\"; $var = $filename."$file"; print $var ; my $document = Win32::OLE -> GetObject("$var"); print "Extracting Text ...\n"; my @array; my $paragraphs = $document->Paragraphs(); my $enumerate = new Win32::OLE::Enum($paragraphs); while(my $paragraph = $enumerate->Next()) { my $text = $paragraph->{Range}->{Text}; $text =~ s/[\n\r\t]//g; $text =~ s/\x0B/\n/g; $text =~ s/\x07//g; chomp $text; my $Data .= $text; @array=split(/\.$/,$Data); foreach my $line( @array) { if ($print_next) { print $out_fh $line ; #No need to chomp - we print t +he "\n" } $print_next = ($line =~ /^Customer\sID : \sYes/); } } } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The output is : ID :123 ID :257 ID :545 ID: 589
I want it to be printed as
ID :123
ID :257
ID :545
ID: 589
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl Script New Line problem
by Ratazong (Monsignor) on Dec 21, 2011 at 08:54 UTC | |
Re: Perl Script New Line problem
by Anonymous Monk on Dec 21, 2011 at 08:53 UTC | |
Re: Perl Script New Line problem
by perl.j (Pilgrim) on Dec 21, 2011 at 15:48 UTC | |
by Anonymous Monk on Dec 21, 2011 at 16:29 UTC | |
by perl.j (Pilgrim) on Dec 21, 2011 at 17:26 UTC | |
by Anonymous Monk on Dec 21, 2011 at 18:55 UTC |