Search a text file ,picking values from array

Discussion in 'Perl Misc' started by sandi_siva@yahoo.com, Mar 5, 2007.

  1. Guest

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


    ############################################################################
     
    , Mar 5, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lily Jost
    Replies:
    13
    Views:
    550
  2. mykidisgollum
    Replies:
    2
    Views:
    290
    david fields
    Oct 10, 2003
  3. Abby Lee
    Replies:
    5
    Views:
    480
    Abby Lee
    Aug 2, 2004
  4. Rita
    Replies:
    14
    Views:
    171
    Jahagirdar Vijayvithal S
    Dec 5, 2005
  5. Peter Hanke
    Replies:
    1
    Views:
    163
    Dr.Ruud
    Jan 6, 2008
Loading...

Share This Page