title: How Can I Read a lot of Colums as a Data in a File and Store Them in a Array Correctly in Perl
body: <p>Right now I am trying to do some comparison with using some datas that are belongs to two different input files.</p>
  
  <p>The first input file looks like this: I have two rows and a lot of columns. </p>
  
  <pre><code>id    date1       time1       date2       time2      ne  CC0 CC1   CC2  CC3  CC4... due to CC127 
  
  1    2016-09-26  14:13:56   2016-09-26  14:08:56    S1   7   1226   0   86    0 
  2    2016-09-26  14:13:56   2016-09-26  14:08:56    S2   8   1346   2   97   12  
  </code></pre>
  
  <p>Second input file looks like this:</p>
  
  <pre><code>ne  type  time threshold
  
  S1  CC000  09   50
  
  S1  CC000  10   50
  
  S1  CC000  11   50
  
  S1  CC000  12   50
  
  S1  CC000  13   50
  
  S1  CC000  14   50
  </code></pre>
  
  <p>My main aim is to read those two files, storing necessary informations and datas in the arrays. If the time(as an hour) and ne condition matches then ı want to compare its data and its threshold value. If data is bigger than the threshold, ı want to keep this data and write them another file as a result. For example, for ne S1, and hour 14, CC0 data is equal to 7 and threshold is equal to 50.</p>
  
  <p>So far ı wrote this codes; ( the last edited one, with help of Chris)</p>
  
  <pre><code>    #! /usr/bin/perl -w
  
  #compiler profilleri
  use strict;
  use warnings;
  
  #dosya locationları
  
  my $input_file="C:/Perl64/output/innput.txt";
  my $s1_threshold="C:/Perl64/output/s1_threshold.txt";
  
  #komutlar######
  
  
  my $date; my $time; my $ne; my @hour; my @cc;
  my $i=0; my $j=0;
  
      open INPUT, "&lt; $input_file" or die "$0: open of $input_file failed, error: $! \n";
  
      while ( defined ($_=&lt;INPUT&gt;) )
      {   
  
          my $line1 = $_;
          my ( undef, $date, $time, undef, undef, $ne, @cc) = split (' ',$line1);
          #print("$cc[16]\n");
  
          my @time1= split(':',$time);
          @hour=split(',',$time1[0]);
  
          #print("@hour\n");
  
      open THR, "&lt; $s1_threshold" or die "$0: open pf $s1_threshold failed, error: $! \n";
      while (defined($_=&lt;THR&gt;) )
      {
          my $line2=$_;
          my ($ne1, $cc_type, $time1, $threshold ) =split(' ',$line2);
  
          if( $hour[0] == $time1 &amp;&amp; $ne eq $ne1 )
          {
              for ( $i=0;$i&lt;128;$i++)
              {
                 if ( $cc[$i] &gt; $threshold )
                 {
                    # print("$cc[$i]\n");
                 }
               }
          }
      }
    }
  </code></pre>
  
  <p>Now ı can obtain all data correctly in a simple way, but when it comes to final if command I mean this,</p>
  
  <pre><code>if ( $      cc[$i] &gt; $threshold )
  </code></pre>
  
  <p>cc array values are being compared with all of the threshold values, not just the value for related cc_type and hour.
  Second input file contains threshold values with respond to cc_types. For each cc_type there are 23 different value with respect to hour so ı want to compare only for that specific hour and cc_type. How can ı fix that?</p>
  
  <p>(When ı figure out the first part for that, ı will add the same procedure by adding another threshold file for S2. )    </p>
  
  <p>ı am a newbie in perl language, so any kind answer related to this appreciated.
  Thanks in advance.
  Regards.</p>