#!/usr/bin/perl -w

use strict;

open(FH, $ARGV[0]);

my $line;
my $is_indexed;
my $filename;
my $event = "";

while ( $line = <FH> ) {

	if ( $line =~ /^-----\ Begin chunk\ -----$/ ) {
		$is_indexed = 0;
		$event = "";
	}

	if ( $line =~ /^Image\ filename: (.*)$/ ) {
		$filename = $1;
	}

	if ( $line =~ /^Event: (.*)$/ ) {
		$event = $1;
	}

	if ( $line =~ /^Cell\ parameters/ ) {
		$is_indexed = 1;
	}

	if ( $line =~ /^-----\ End chunk\ -----$/ ) {
		if ( $is_indexed ) {
			printf("%s", $filename);
			if ( $event ) {
				printf(" %s\n", $event);
			} else {
				printf("\n");
			}
		}
	}


}
