in reply to Re^8: how to check if a particular value exist in list of files stored in an array
in thread how to check if a particular value exist in list of files stored in an array
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
|
|---|