-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.pl
More file actions
executable file
·32 lines (31 loc) · 883 Bytes
/
Copy pathtest.pl
File metadata and controls
executable file
·32 lines (31 loc) · 883 Bytes
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
#!/usr/bin/perl
$lastln = "";
$lastLnMatched = 0;
$lnNo = 0;
while ($ln = <>) {
$lnNo++;
# Look at the current line to look for " 4:27" like lines
if (($ln =~ /^\s+[0-9]+:[0-9]+/) &&
($lastLnMatched == 1)) {
# We have a match with this line and the previous
print "\\p"; # And no newline; rest will print below
}
elsif ($lastLnMatched == 1) {
# We matched a \p with nothing else on the line,
# thought it might be one of interest to us, but
# it was not. So, we have to print it out so it doesn't
# get "lost."
print "\\p\n"; # Newline = next print is a new line!
}
if ($ln =~ /^\\p$/) {
# Maybe going to be a match the next line
#print "Match could be coming [$lnNo]: $ln";
$lastLnMatched = 1;
# Don't print it yet
}
else {
$lastLnMatched = 0;
print $ln;
}
$lastln = $ln;
}