#!/usr/local/bin/perl
#
#  Mugshot - a utility to extract SUSPECT info from command.log
#
#  Usage:
#	mugshot command.log
#	cat command.log | mugshot
#
#  Produces a set of files called SUSPECT<db#>.log. It appends to these
#  files, so you may want to truncate them now and then.
#
# Idea by Alan Schwartz (Javelin/Paul), code by Talek, some revision by Paul

while ($line = <>) {
	if ($line =~ /SUSPECT[^#]*(#\d+)/) {
		$num = $1;
		unless (defined ($file{$num})) {
			$file{$num} = "foo$num";
			open ($file{$num}, ">>SUSPECT$num.log");
		}
		select ($file{$num});
		print $line;
	}
}

for $file (values (%file)) {
	close $file;
}


