blob: cd3ba2888bc9ca880e130edd9d33826ed49c5fc6 (
plain) (
blame)
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
|
use strict;
use warnings;
use open ':encoding(ISO-8859-1)';
use IO::Uncompress::Gunzip qw($GunzipError);
($,, $\) = ("\t", "\n");
for my $rfc (<*.txt.gz>) {
my $handle = new IO::Uncompress::Gunzip $rfc
or die "${rfc}: ${GunzipError}";
while (<$handle>) {
chomp;
# Section headings
if (/^([\d.]+|[A-Z][.])\s+([^\t]+)/) {
print $1, $rfc, $.;
print $2, $rfc, $.;
}
# References
if (/^\s*(\[[\w-]+\])\s{2,}/) {
print $1, $rfc, $.;
print "\\$1", $rfc, $.; # vim ^] prepends \ to [
}
}
die "${rfc}: $!" if $!;
close $handle;
}
|