blob: f8d6019d04db5d61856a78114aad44be093c0b29 [file] [log] [blame]
Theodore Ts'o9d564f71999-07-03 20:25:58 +00001#!/usr/bin/perl
2#
3# wordwrap.pl --- does word wrap
4#
5while (<>) {
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}