Search a text file ,picking values from array

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";


############################################################################
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top