use strict; use warnings; # An input LOG file which holds information about different users. my $file_name = "QoEWeb_DB_Log.txt"; open(my $sw, '<', $file_name) or die "$file_name: $!"; #Will write the result into an OUTPUT file. open(my $file, '>', 'output.txt') or die "output.txt: $!"; foreach ( sort { $a->[8] <=> $b->[8] } map { [ split /:/ ] } <$sw> ) { my ($field1, $field2, $key1, $field5) = @$_[2,4,8,6]; my @file_name1 = ("Carlo_Arnold_2.232_Final.txt", "Sohaib_Ahmad_2.225_Fi nal.txt"); #Input LOG files; Each file holds informaton about Individual user. I will be adding about 30 files here. foreach my $file (@file_name1) { open(my $rw,$file) or die "$file: $!"; while (<$rw>) { my @ff_array = split(/:/,$_); #Taking required fields fr om the second set of input files. my $key2 = $ff_array[0]; my $field3 = $ff_array[1]; if( $key1 == $key2) # Finding a match between the two in put files { print $file "$field1:$field2:$key1:$field5:$fie ld3"; #Printing the desired result from both batch of input files. } } close($rw) or die "ERROR CLOSING FILE: $!"; } } close $file or die "ERROR CLOSING FILE: $!"; close $sw or die "ERROR CLOSING FILE: $!";