#!usr/bin/perl use strict; use warnings; my $file_name; my $field1; my $field2; my $key1; my $key2; my $field5; my $field3; my $k; my $j; my $x; my $eachline = 0; my $eachline1 = 0; my @logarray; my @ff_array; my @file_name1; $k = 1; $file_name = "QoEWeb_DB_Log.txt"; #An input LOG file which holds information about different users. open(SW,$file_name) or die "ERROR OPENING IN FILE"; open FILE, ">output.txt" or die "ERROR..unable to write" ; #Will write the result into an OUTPUT file. for (sort ) { chomp($eachline); @file_name1 = ("Carlo_Arnold_2.232_Final.txt", "Sohaib_Ahmad_2.225_Final.txt"); #Input LOG files; Each file holds informaton about Individual user. I will be adding about 30 files here. @logarray = split(/:/,$_); # Taking required fields from the first input file. $field1 = $logarray[2]; $field2 = $logarray[4]; $key1 = $logarray[8]; $field5 = $logarray[6]; $x = scalar(@file_name1); for($j=0;$j<$x;$j++) { open(RW,$file_name1[$j]) or die "ERROR OPENING IN FILE"; for (sort ) { chomp($eachline1); @ff_array = split(/:/,$_); #Taking required fields from the second set of input files. $key2 = $ff_array[0]; $field3 = $ff_array[1]; if( $key1 == $key2) # Finding a match between the two input files { print FILE "$field1:$field2:$key1:$field5:$field3"; #Printing the desired result from both batch of input files. } } } } close FILE; close SW or die "Cannot close"; close RW or die "Cannot close";