cvs commit: perlfaq/bin splitfaq

[email protected] (brian d foy) 27 Mar 2005 08:21:50 -0000
Newsgroups perl.cvs.perlfaq
Message-ID <[email protected]>
cvsuser     05/03/27 00:21:50

  Modified:    bin      splitfaq
  Log:
  * Somehow the number counting was wrong, so the last answer in a
  perlfaq\d became the first answer in the text series: for instance,
  faq 7.29 got put into perlfaq.08.00.txt.  I fixed that, although
  the result is not pretty. I'd probably have an easier time with that
  if I didn't use <>.
  
  Revision  Changes    Path
  1.3       +31 -28    perlfaq/bin/splitfaq
  
  Index: splitfaq
  ===================================================================
  RCS file: /cvs/public/perlfaq/bin/splitfaq,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- splitfaq	11 Jul 2002 05:48:16 -0000	1.2
  +++ splitfaq	27 Mar 2005 08:21:50 -0000	1.3
  @@ -18,46 +18,49 @@
   my $faq;
   my ($major, $minor, $revision, $subject);
   
  -$major = 0;
  -
   while (<>) {
   
  -    if (/^perlfaq(\d)*.*Revision/) {
  -	chomp;
  -	$major = $1;
  -	$minor = 0;
  -	($revision = $_) =~ s/(?=\()/\n    /;
  -	next;
  -    }
  +	my $old_major = $major;
  +	($major) = $ARGV =~ /^perlfaq(\d)/g;
  +	
  +	unless( $old_major == $major )
  +		{
  +		printfaq( $old_major, $minor );
  +		$minor = 0;
  +		$faq = '';
  +		redo;
  +		}
  +		
  +	$minor = 0 unless $old_major == $major;
   
       if (/^=head1\s+/) {
  -	$skip = 1;
  -	next;
  -    } 
  +		$skip = 1;
  +		next;
  +		} 
   
       if (/^=head2\s+/) {
  -	$skip = 0;
  -	if ($faq) {
  -	    printfaq();
  -	}
  -	$faq = $_;
  -	$minor++;
  -	for ($subject = $_) {
  -	    s///;
  -	    s/\n/ /g;
  -	}
  -	next;
  -    } 
  +		$skip = 0;
  +		if ($faq) {
  +			printfaq( $major, $minor );
  +			}
  +		$faq = $_;
  +		$minor++;
  +		for ($subject = $_) {
  +			s///;
  +			s/\n/ /g;
  +			}
  +		next;
  +    	} 
   
       unless ($skip) {
  -	$faq .= $_;
  -    }
  +		$faq .= $_;
  +		}
   
   }
   
  -printfaq();
  -
   sub printfaq {
  +	my( $major, $minor ) = @_;
  +	
       my $faqname = sprintf("perlfaq.%02d.%02d.txt", $major, $minor);
       print STDERR "$faqname\n";
       open (F, "| pod2text > $dir/$faqname")