#!/usr/bin/perl -w use strict; my ($number, $author, $title, $month, $year); while(<>) { last if m/^------/; } while (<>) { chomp; s/ & / \\& /; if ($_ =~ m/^RFC\d{4} \|[^|]*\| (.+), \"(.*)\",.* RFC (\d+), (\S*) [\d ]*(\d{4})\s*\.\s*$/) { ($author, $title, $number, $month, $year) = ($1, $2, $3, $4, $5); # Special cases for known brokennesses $author =~ s/Eastlake, D., 3rd/D. Eastlake 3rd/; $author =~ s/Nesser, P., II/P. Nesser II/; $author =~ s/Murphy, T., Jr./T. Murphy Jr/; # Months into bibtex format: jan, feb, mar ($month = substr($month, 0, 3)) =~ tr/[A-Z]/[a-z]/; # Authors into bibtex format "A. foo and B. Bar and C. Baz" $author =~ s/([^ ,][^,]*[^.]), ([^,]+\.)($|, ?(and )?| and )/$2 $1 and /g; $author =~ s/ and $//; # More special cases for known brokennesses $author =~ s/and WG Chair,/(WG Chair) and /; $author =~ s/and Chair,/(Chair) and /; $author =~ s/(NetBIOS Working Group in the Defense Advanced Research Projects Agency)/{$1}/; $author =~ s/(End-to-End Services Task Force)/{$1}/; $author =~ s/(Internet Activities Board)/{$1}/; $author =~ s/(ESCC X.500\/X.400 Task Force)/{$1}/; $author =~ s/(RARE WG-MSG Task Force 88)/{$1}/; $author =~ s/(Audio-Video Transport Working Group)/{$1}/; $author =~ s/(ESnet Site Coordinating Comittee)/{$1}/; $author =~ s/(Energy Sciences Network)/{$1}/; $author =~ s/\s*, (and )?/ and /g; # Back to the first special case again: let bibtex know # that "Eastlake" is not his middle name. $author =~ s/D. Eastlake 3rd/Eastlake 3rd, D./; $author =~ s/P. Nesser II/Nesser II, P./; $author =~ s/T. Murphy Jr/Murphy Jr, T./; print "\@techreport{RFC$number,\n"; print " key = \"RFC$number\",\n"; print " author = \"$author\",\n"; print " title = \"{$title}\",\n"; print " month = $month,\n" if $month ne ""; print " year = $year,\n"; print " type = \"{RFC}\",\n"; print " number = \"$number\"\n"; print "}\n"; print "\n"; } else { die "Bad line: $_" unless m/\" Not Issued \"/; } }