On Jul 2, Pedro A Reche Gallardo said:

>1 0.057         M
>2 0.819         R
>3 0.731         V
>4 0.708         K
>5 0.070         G
>6 0.611         I
>7 0.055         +
>8 0.748         +
>9 0.864         N
>10 0.146        a
>11 1.782        Q
>12 2.707        +
>13 0.893        .
>14 1.252        L
>15 0.659        W
>16 2.150        +
>17 1.137        W
>18 0.976        G
>19 2.022        .
>20 0.147        .
>21 0.124        .
>
>The number on the second column goes from 0 to 4.3 and the files are
>really long (around 1000 lines).  What I would like to do, is to find
>out the file stretches  that contain at least 9 consecutive rows with a
>value in the second column lower that 1, and storing the character of
>the third column.

You want to do some simple splitting:

  my @run;

  open FILE, "< $file" or die "can't read $file: $!";
  while (<FILE>) {
    my ($line, $val, $char) = split;

    if ($val > 1) {
      print @run, "\n" if @run > 9;
      @run = ();
      next;
    }

    push @run, $char;
  }
  close FILE;

That does it rather simply.  If you want to keep the line numbers
recorded, you'll have to keep track of those as well.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **


Reply via email to