#!/usr/bin/perl -w $TOCHEADER=" TABLE OF CONTENTS"; open(O, ">FAQ.html"); # Load FAQ into memory while(<>) { push (@faqfile, $_); } my $current_line = 0; my $version; # Skip header up to table of contents while($current_line <= $#faqfile) { $_ = $faqfile[$current_line]; $current_line++; if (/Net-SNMP Version: (.*)/) { $version = $1; } last if (/$TOCHEADER/); } print O '

FAQ

FAQ Maintainer: Dave Shield
Email: net-snmp-coders@list.sourceforge.net
'; print O "Version: $version
\n"; print O '

Table of Contents

'; # Create table of contents while($current_line <= $#faqfile) { $_ = $faqfile[$current_line]; #Skip blank lines if (/^\s*$/) { $current_line++; last; } chomp(); # Remove white space at start of line $_ =~ s/^ *//; $x = $_; # Remove white space at start of line $x =~ s/^ *//g; # Replace all non alpha characters with _ $x =~ s/[^a-zA-Z]/_/g; # Save cleaned up line $xlate{$_} = $x; if ( /&/ ) { $_ =~ s/&/&/g; } if ( // ) { $_ =~ s/>/>/g; } if (/^[ A-Z]+$/) { # Section header (eg: GENERAL) print O "$_
\n";

# Print contents with targets defined
while($current_line <= $#faqfile) {
    $_ = $faqfile[$current_line];
    $current_line++;

    chomp();

    $y = $_;

    if (defined($xlate{$y})) {
	print O "\n";
    }
    if ( /&/ ) { $_ =~ s/&/&/g; }
    if ( // ) { $_ =~ s/>/>/g; }
    print O "$_\n";
}

print O '
';