#!/usr/bin/perl $q = 1; # Modified by Edwin Lima (edwinlima@hotmail.com; edwin.lima@nec-computers.com) # Date: 08/21/01, The Netherlands # $f: Variable used as a flag to create the list of questions on top of the question-answers set. This # is the only way that I found to scan the questions which have a , in such a way that I will not # scan the answer together at same time. # @aname: Buffer used to store the question-answers set to print them out just after the print of the # questions. # @href: Buffer used to store the anchors (only questions) to the questions-answers set on the bottom # of the page. # I opened explicitly the file for input (input.txt) but U can change this as it was originally. # # #comment this line if you are not open the file explicitly #open(IN, "input.txt") || die "cannot open file input.txt" ; print("") ; #Uncomment line bellow to make it work as it was originally. while (<>){ #comment line bellow #while (){ chop; if (/^\* (.*)$/){ push(@aname,"

$1

\n"); # print $body; } elsif (/^\*\* (.*)$/) { push(@aname, "

$1

\n"); push(@href, "

$1

\n"); } elsif (/^\*\*\* (.*)$/) { push(@aname, "

$1

\n"); } elsif (/^$/) { push(@aname, "

\n"); # push(@href, "

\n"); NOT NEEDED } elsif (/^\t\t\* (.*)$/) { push(@aname, "

  • $1\n"); } elsif (/^Q: (.*)$/){ push(@aname, "

    Question $q: $1\n"); push(@href,"

    Question $q: $1\n"); $f=1; $q++; } elsif (/^A: (.*)$/){ push(@aname,"

    \nTop\n

    "); push(@aname,"$1\n"); $f=0; } elsif (/^TODO=(.*),$/){ push(@aname, "\n"); #push(@href, "\n"); } else { push(@aname,"$_\n"); if ($f==1) { push(@href,"$_\n"); } } } foreach $line (@href) #"\n\n"; { print $line; } foreach $line (@aname) #"\n\n"; { print $line; } #comment this line if you are not open the file explicitly # close(IN) || die "cannot close file" ;