﻿#!/usr/bin/perl -w
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);
use integer;


# Filter_2_02_check_pb.pl
# 2010-04-16
# Wolfgang Schmidle

# what does it do?
# input
# output


# text input

my @text;
while(<>) { push @text, $_; }


# go through the text

my $i = 0;
my $pb = 0;
my $offset = "";
my $nextline = "";

foreach (@text) {

	$i++;
	if (m!<pb.+<pb!) { die "Line $i: more than one <pb> in one line:\n$_\n"; }
	if (m!<pb!) {
		$pb++;
		$offset = (m!<pb (\d+)>! ? " offset ".($pb-$1) : "");
		$nextline = (exists $text[$i] && $text[$i] !~ m!<pb! ? "  $text[$i]" : "" );
		warn "pb $pb (line $i)$offset\n  $_$nextline\n";
	}
}

die "That's all.\n";
