#! /usr/bin/perl
use warnings;
use strict;
use integer;
use FindBin;
use lib $FindBin::RealBin;
use Def;

our %opt = map {$_=>1} @ARGV;
# The present version provides no options.

# You do not need this optional helper script to install, use, modify,
# develop, build, package or distribute `debram'.  If you are developing
# the debram, however, you may possibly find the script convenient.
#
# This brief script strips the top- and bottommatter from debram.txt.
# It acts as a filter, taking the full debram.txt on stdin, printing the
# stripped debram.txt on stdout.  It also verifies that each ram shows
# the correct package count.

1 while <> ne $Def::mark_main_body; <>;
$/ = '';
while ( <> ) {
    chomp; $_ .= "\n\n";
    my @c; push @c, $1 while s/\A(.*\n)//;
    $c[1] =~ /(\d{4}) .+? \((\d+)\)/ or last;
    @c-4 == $2 or die "miscount on ram $1\n";
    @c = @c[3..$#c-1] if $opt{strip_title};
    print @c;
}

