Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Search a text file ,picking values from array

Reply
Thread Tools

Search a text file ,picking values from array

 
 
sandi_siva@yahoo.com
Guest
Posts: n/a
 
      03-05-2007
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";


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read 10 values at a time from a text file out of 50 values in VHDL shrutisunder VHDL 0 03-11-2009 06:10 AM
| SEO , Search Engine Optimizer, SEARCH OPtiMIzAtIoN with SeaRch OPtiMizer optimizer.seo@gmail.com Digital Photography 0 04-22-2007 04:20 AM
Re: text file search to text file output possible? Whiskers Computer Support 3 10-07-2006 06:32 PM
Re: text file search to text file output possible? Mitch Computer Support 0 10-06-2006 11:15 PM
search within a search within a search - looking for better way...my script times out Abby Lee ASP General 5 08-02-2004 04:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57