File: clean-nroff.pl

package info (click to toggle)
enscript 1.6.5.90-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 7,264 kB
  • ctags: 4,824
  • sloc: ansic: 33,705; sh: 5,383; makefile: 649; yacc: 457; lex: 428; perl: 340; lisp: 109; sed: 16
file content (44 lines) | stat: -rwxr-xr-x 497 bytes parent folder | download | duplicates (10)
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
#!/usr/local/bin/perl -w

sub skip_lines {
    ($count) = @_;

    while ($count > 0) {
	if (!<>) {
	    last;
	}
	$count--;
   }
    if ($count > 0) {
	return 0;
    }
    return 1;
}

sub print_lines {
    ($count) = @_;

    while ($count > 0)  {
	$line = <>;
	if (!$line) {
	    last;
	}
	print $line;
	$count--;
    }

    if ($count > 0) {
	return 0;
    }
    return 1;
}

# Header.
print_lines(7);

# Process file.
while (1) {
    if (!print_lines(52) || !skip_lines(14)) {
	last;
    }
}