I think you need to sort <SW> rather than <RW>

It is good that you have added 'use strict' and declared all your variables with 'my'. It is generally best to declare your variables in the smallest possible scope, rather than declaring them all at file scope.

You are chomping $eachline and $eachline1, which you are not setting or using. These statements can be removed.

It is better to use the three argument form of open

The following is untested, as I have no input data to test with.

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_Ahma +d_2.225_Fi nal.txt"); #Input LOG files; Each file holds informaton about Individu +al 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:$f +ield5:$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: $!";

In reply to Re^5: a little problem with sorting my data by ig
in thread a little problem with sorting my data by aash08

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.