#!/usr/bin/perl -w

my $pattern= qr/\/Matrix \[0?\.707 0?\.707 -0?\.707 0?\.707 /o;

my $chunk= "";
my $n=0;

while (<>) {
  if ($n == 0) {
    if (/obj/) {
      $chunk= $_;
      $n++;
    } else {
      print;
    }
  } else {
    $chunk.= $_;
    if (/^endobj/) {
      if ($chunk =~ $pattern) {
        print STDERR "skipping chunk #$n\n";
      } else {
        $chunk =~ s/kostenloser Download von www\.raupenhaus\.de/ /gio;
        print $chunk;
      }
      $chunk= "";
      $n++;
    }
  }
}

if ($chunk) {
  print $chunk;
}
