summaryrefslogtreecommitdiffstats
path: root/fbench/util/separate.pl
blob: 429ea4d0e37334f3e718df11faba8e57821e637f (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 2016 Yahoo Inc. 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";
  }
}