#!/usr/bin/perl -w # build_snapshot.pl - Don Yang (uguu.org) # # Build snapshot from event log. This uses a more simplistic routine # for reconstructing the file contents, useful for debugging # correctness of the event compiler. # # All cursor+timestamp events are ignored. To build a partial # snapshot up to some event, feed the input through head(1). For # example: # head -1000 input.log | ./build_snapshot.pl > output.txt # # 06/27/11 use strict; my @lines = (); while( my $input = <> ) { chomp $input; next unless $input =~ /^L(\d+)E(\d+)=(.*)/; $lines[$1] = $3; $#lines = $2; } for(my $i = 1; $i <= $#lines; $i++) { if( defined $lines[$i] ) { print $lines[$i], "\n"; } else { print "\n"; } }