#!/usr/bin/perl
#
my ($line)    = "";
my ($picture) = "";
my ($save)    = 0;
#
while ($line = <STDIN>)
  {
    if    ($line =~ m/^\%\%BeginDocument: (\S+)$/)
      {
        $save = 1;
        $picture = $1;
        open (PICTURE, "> $picture");
      }
    elsif ($line =~ m/^\%\%EndDocument$/)
      {
        close (PICTURE);
        $picture = "";
        $save = 0;
      }
    else
      {
        if ($save)
          {
            print PICTURE ("$line");
          }
      }
  }
