#!/usr/bin/perl -w
# Expand 'last message repeated N times' syslog log messages to repeat
# the previous line N times.
# Usage: expsyslog.pl [file1 [file2 ...]]. In the grand Unix tradition
# it eats stdin if given no arguments.
use strict;
my $last;
while (<>) {
	if (/^... +\d+ \d+:\d+:\d+ [^ ]+ last message repeated ([0-9]+) times\n$/) {
		print $last x $1
	} else {
		$last = $_;
		print $last;
	}
}
