ietf
[Top] [All Lists]

Re: RFC 6234 code

2013-06-28 19:59:24
Dearlove, Christopher (UK) wrote:

I'd actually tried the authors, but no reply yet (only a few days).
I also tried the RFC Editor thinking they might have e.g. XML
from which extraction might have been easier, but also no response yet.

Extracting code from text is pretty trivial.

Use copy&paste from the output of below simple perl script
(which removes the pagebreaks):


-Martin


#!/usr/bin/perl
#
$rfcnum="6234";
$footerpattern="^Eastlake";
$headerpattern="^RFC ${rfcnum}";

$url = "http://tools.ietf.org/rfc/rfc${rfcnum}.txt";;

open(IN,"curl '${url}'|")
  || die("Download of \"$url\" failed: $!\n");
@doc  = ();
$show = 2;
while($line = <IN>) {
    $line =~ tr/\r\n//d;
    if ( $line =~ m/${footerpattern}/io ) {
        $show = 0;
        while ( $doc[$#doc] eq "" ) {
            pop(@doc);
        }
    }
    if ( $show>0 ) {
        if ( 2==$show || $line ne "" ) {
            push(@doc, $line);
            $show = 2;
        }
    }
    if ( 0==$show && $line =~ m/^${headerpattern}/ ) {
        $show = 1;
    }
}

close(IN);

print join("\n",@doc), "\n";


<Prev in Thread] Current Thread [Next in Thread>