S
sandi_siva
HI I am trying to automate a PPD file
Basic concept is Pick up the values from excel sheet and search it in
a text file.
I am able to display the values from the excel sheet.
Even i am able to search single value in the text file.
Please can some body help me in looping it up so that.
Values are taken up from the array one by one and searched in the text
file and results are updated
Thanks in advamce
the code is
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE::Const 'Microsoft Word';
use File::Find;
# $Win32::OLE::Warn = 3; # die on
errors...
##########################Excel Start Here####################
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application'); # get already active
Excel
# application or
open new
my $Book = $Excel->Workbooks->Open("C:\\PNP and PPD scenarioS.xls"); #
open Excel file
my $Sheet = $Book->Worksheets(1);
$Excel->{'Visible'} = 1;
my $array = $Sheet->Range("B35:B100")->{'Value'}; # get the
contents
$Book->Close;
foreach my $ref_array (@$array) { # loop through
the array
# referenced by
$array
foreach my $scalar (@$ref_array) {
print "$scalar\t"; #values are displayed till
defined in the range;
}
print "\n";
}
#print "$array\t\n";
This works for only one key word.
########################Searching Part#########################
sub find_first {
my $regex = shift;
local @ARGV = @_;
while (<>) {
return $_ if /$regex/
}
}
my $line = find_first(qr/$array/, 'C:\\EF3X3323.txt');
print "$line";
############################################################################
Basic concept is Pick up the values from excel sheet and search it in
a text file.
I am able to display the values from the excel sheet.
Even i am able to search single value in the text file.
Please can some body help me in looping it up so that.
Values are taken up from the array one by one and searched in the text
file and results are updated
Thanks in advamce
the code is
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE::Const 'Microsoft Word';
use File::Find;
# $Win32::OLE::Warn = 3; # die on
errors...
##########################Excel Start Here####################
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application'); # get already active
Excel
# application or
open new
my $Book = $Excel->Workbooks->Open("C:\\PNP and PPD scenarioS.xls"); #
open Excel file
my $Sheet = $Book->Worksheets(1);
$Excel->{'Visible'} = 1;
my $array = $Sheet->Range("B35:B100")->{'Value'}; # get the
contents
$Book->Close;
foreach my $ref_array (@$array) { # loop through
the array
# referenced by
$array
foreach my $scalar (@$ref_array) {
print "$scalar\t"; #values are displayed till
defined in the range;
}
print "\n";
}
#print "$array\t\n";
This works for only one key word.
########################Searching Part#########################
sub find_first {
my $regex = shift;
local @ARGV = @_;
while (<>) {
return $_ if /$regex/
}
}
my $line = find_first(qr/$array/, 'C:\\EF3X3323.txt');
print "$line";
############################################################################