1 |
#!/usr/bin/perl -w
|
2 |
|
3 |
if ($#ARGV != 2-1 ) {
|
4 |
print "usage: perl getHLTRelease.pl HLTFile CurrentRun\n";
|
5 |
exit;
|
6 |
}
|
7 |
|
8 |
$HLTFile = $ARGV[0];
|
9 |
$CurrentRun = $ARGV[1];
|
10 |
|
11 |
$notfound = 1;
|
12 |
|
13 |
open (TEXT_FILE, $HLTFile);
|
14 |
$run = $CurrentRun;
|
15 |
|
16 |
while ($line = <TEXT_FILE>) {
|
17 |
if ($line !~ "#") {
|
18 |
my @pieces = split(' ', $line);
|
19 |
if($pieces[1] <= $run && $pieces[2] >= $run) {
|
20 |
my $release = $pieces[0];
|
21 |
print "$release";
|
22 |
$notfound = 0;
|
23 |
last;
|
24 |
}
|
25 |
}
|
26 |
elsif ($line =~ "EOF") {
|
27 |
last;
|
28 |
}
|
29 |
}
|
30 |
close (TEXT_FILE);
|
31 |
|
32 |
open (TEXT_FILE, $HLTFile);
|
33 |
if ($notfound == 1 ) {
|
34 |
while ($line = <TEXT_FILE>) {
|
35 |
if ($line !~ "#") {
|
36 |
my @parts = split(' ', $line);
|
37 |
if ($parts[1] > $run) {
|
38 |
print "-1";
|
39 |
last;
|
40 |
}
|
41 |
$nextline = <TEXT_FILE>;
|
42 |
my @nextparts = split(' ', $nextline);
|
43 |
if($parts[2] < $run && $nextparts[1] > $run) {
|
44 |
my $release = $parts[0];
|
45 |
print "$release";
|
46 |
last;
|
47 |
}
|
48 |
elsif ($line =~ "EOF") {
|
49 |
print "-1";
|
50 |
last;
|
51 |
}
|
52 |
else {
|
53 |
$line = $nextline;
|
54 |
redo;
|
55 |
}
|
56 |
}
|
57 |
}
|
58 |
}
|
59 |
close (TEXT_FILE);
|
60 |
|
61 |
|