summaryrefslogtreecommitdiffstats
path: root/fbench/util/separate.pl
blob: a164b196ae763fc4ca58c331816050d727d3828b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

$sepcol = shift;

if ($sepcol eq "") {
  die qq{usage: separate.pl <sepcol>
       Separate a tabular numeric file into chunks using a blank
       line whenever the value in column 'sepcol' changes.
};
}

$oldval = -2;
$newval = -2;

while (<>) {
  if (/^#/) {
    print;
  } else {
    chomp;
    @vals = split;
    $newval = $vals[$sepcol];
    if ($newval != $oldval) {
      print "\n";
      $oldval = $newval;
    }
    print "@vals\n";
  }
}