title: print n users and their value using perl
body: <p>I am new to perl require your help to build a logic.</p>
  
  <p>I have some let say 10 files in a directory, each file has some data like below. Each file contain lines depends upon the number of users setting. For example if 4 users are there then 4 lines will get printed from the server.</p>
  
  <pre><code>1405075666889,4044,SOA_breade,200,OK,Thread Group 1-1,text,true,623,4044
  1405075666889,4041,SOA_breade,200,OK,Thread Group 1-1,text,true,623,4041
  1405075666889,4043,SOA_breade,200,OK,Thread Group 1-1,text,true,623,4043
  1405075666889,4045,SOA_breade,200,OK,Thread Group 1-1,text,true,623,4044
  </code></pre>
  
  <p>I want to some piece of logic that should create single file in a output directory and that file should contain 10 lines </p>
  
  <pre><code>Min_Value, Max_Value, Avg_Value, User1, User2, User3......User4
  </code></pre>
  
  <p>and their corresponding values from second line in this case corresponding values are coming from second column.</p>
  
  <pre><code>Min_Value, Max_Value, Avg_Value, User1, User2, User3......User4
  4.041,4.045,4.044,4.041,4.043,4.045
  .
  .
  .
  .
  .
  </code></pre>
  
  <p>10th file data</p>
  
  <p>Here is my code... It is working however <strong>I am not getting how to print user1, user2... in sequence and its corresponding values</strong> </p>
  
  <pre><code>my @soaTime;
  my @soaminTime;
  my @soamaxTime;
  my @soaavgTime;
  my $soadir = $Json_Time;
  foreach my $inputfile (glob("$soadir/*Overview*.txt")) {
      open(INFILE, $inputfile) or die("Could not open  file.");
      foreach my $line (&lt;INFILE&gt;)  {
  
          my @values = split(',', $line); # parse the file
          my $time_ms = $values[1]/1000;
          push (@soaTime, $time_ms);
      }
  
      my $min = min @soaTime;
      push (@soaminTime, $min);
      print $soaminTime[0];
      my $max = max @soaTime;
      push (@soamaxTime, $max);
      sub mean { return @_ ? sum(@_) / @_ : 0 };
      #print mean(@soaTime);
      push (@soaavgTime, mean());
      close(INFILE);
  }
  
  my $outputfile = $report_path."abc.txt";
  open (OUTFILE, "&gt;$outputfile");
  print OUTFILE ("Min_Value,Max_Value,User1,User2,User3,User4"."\n"); # Prining the data
  for (my $count = 0; $count &lt;= $#soaTC; $count++) {
      print     OUTFILE("$soaminTime[0],$soamaxTime[0],$soaTime[0],$soaTime[1],$soaTime[2],$soaTime[3]"."\n"     );           #Prining the data
  }
  close(OUTFILE);
  </code></pre>
  
  <p>Please help.</p>