-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
hotdog-modifyToSwapMonitors::.pl
executable file
·70 lines (63 loc) · 1.14 KB
/
hotdog-modifyToSwapMonitors::.pl
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env perl
$matchName1 = shift @ARGV;
$matchName2 = shift @ARGV;
if (not $matchName1 or not $matchName2) {
while ($line = <STDIN>) {
print $line;
}
exit 0;
}
if ($matchName1 eq $matchName2) {
while ($line = <STDIN>) {
print $line;
}
exit 0;
}
@lines = <STDIN>;
chomp @lines;
$matchLine1 = undef;
$matchLine2 = undef;
foreach $line (@lines) {
$name = undef;
next if ($line !~ m/\boutput:([^\s]+)/);
$name = $1;
if ($name eq $matchName1) {
$matchLine1 = $line;
}
if ($name eq $matchName2) {
$matchLine2 = $line;
}
}
if ($matchLine1 and $matchLine2) {
foreach $line (@lines) {
if ($line eq $matchLine1) {
print <<EOF;
$matchLine2
EOF
} elsif ($line eq $matchLine2) {
print <<EOF;
$matchLine1
EOF
} else {
print <<EOF;
$line
EOF
}
}
} else {
foreach $line (@lines) {
print <<EOF;
$line
EOF
}
if (not $matchLine1) {
print <<EOF;
output:$matchName1 rotate:normal
EOF
}
if (not $matchLine2) {
print <<EOF;
output:$matchName2 rotate:normal
EOF
}
}