#!/usr/bin/perl -w # optimize_log.pl - Don Yang (uguu.org) # # Optimize output of record.vim # # ./optimize_log.pl < log.txt > optimized_log.txt # # 05/22/11 use strict; my $timestamp = ""; my @lines = (); while( my $input = <> ) { if( $input =~ /^Y(\d+X\d+F\d+T\d+)/ ) { # Update cursor or timestamp if( $timestamp ne $1 ) { print $input; $timestamp = $1; } } elsif( $input =~ /^L(\d+)E(\d+)=(.*)/ ) { # Snapshot line if( !(defined $lines[$1]) || $lines[$1] ne ($2 . $3) ) { print $input; $#lines = $2; $lines[$1] = $2 . $3; } } }