Hi Experts,

As mentioned in my pervious posts, i have condition-file which contains data as...

condition-file --------------- K 01 J 02 I 03 H 04

i have input files where i have stored all the files in a array called @filelist, which may be file1,fie2,....filen.Each file contains record like...

file1 ------- K,01,data,japan,jung,kcika,Kisjl,01234 J,02,thaja,China,cunk,Jksb,Yjski,23456

i need to take first element from the condition-file and need to check if it exists in all files exist in @filelist for example, i have taken the first element from condition-file, K and will check if this exists in each file in @filelist check in file1, if exists print the line to output text file, check file 2 and do the same till filen

i have code which is taking more than 1 hour.Although it works fine, it takes very long time, 30 min to 1 hour. I also tried following Perl script

foreach my $file_name (@array) { open FILE, "$file_name" or die "File not exists"; while ( my $line = <FILE> ) { my ( $field1, $field2 ) = split /\,/, $line; if (exists $records{$field1}) { $field_2 = $records{$field1}; if( $field2 eq $field_2 ) { print OUTPUT $line; } } } }

I was wondering if someone could suggest a solution


In reply to Re^9: how to check if a particular value exist in list of files stored in an array by Perlseeker_1
in thread how to check if a particular value exist in list of files stored in an array by Perlseeker_1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.