Theodore Ts'o | 9d564f7 | 1999-07-03 20:25:58 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl |
2 | # | ||||
3 | # wordwrap.pl --- does word wrap | ||||
4 | # | ||||
5 | while (<>) { | ||||
6 | if (/^#/) { # don't word wrap comments | ||||
7 | print; | ||||
8 | next; | ||||
9 | } | ||||
10 | next if (/^$/); # skip blank lines | ||||
11 | $linelen = 0; | ||||
12 | split; | ||||
13 | while (defined($word = shift @_)) { | ||||
14 | if ($linelen > 0) { | ||||
15 | printf(" "); | ||||
16 | } | ||||
17 | $len = length($word) + 1; | ||||
18 | $linelen += $len; | ||||
19 | if ($linelen > 78) { | ||||
20 | printf("\\\n "); | ||||
21 | $linelen = 1+$len; | ||||
22 | } | ||||
23 | printf("%s", $word); | ||||
24 | } | ||||
25 | printf("\n"); | ||||
26 | } |