#!/usr/bin/perl -w use strict; use Debian::Debhelper::Dh_Lib; init(); sub gettoc { my $f = shift; my @toc; open(FILE, "<$f") || die("opening $f: $!\n"); while () { chomp; /^\d+\.\s/ && push(@toc, $_); } close(FILE) || die("closing $f: $!\n"); return @toc; } my @entoc = gettoc("developers-reference.txt"); # sanity test if ( $#entoc == -1 ) { error("found no entries in the TOC, aborting"); } elsif ( $#entoc < 4 ) { error("only found " . $#entoc . " entries in the TOC, aborting"); } verbose_print("found " . $#entoc . " entries in TOC"); my $entoc = " " . join('${Newline} ', @entoc); foreach my $package (@{$dh{DOPACKAGES}}) { addsubstvar($package, "TOC:en", $entoc); }