use strict; use warnings; my (@pre, @post, @busy); my $state = 'pre'; while (<>) { next if /^\s*$/; if ($state eq 'pre') { if (/^ab starts$/) { $state = 'busy'; next; } if (/^(\d+\.\d+) KB$/) { push @pre, $1; next; } die "Bad line: $.: $_"; } if ($state eq 'busy') { if (/^ab quits$/) { $state = 'post'; next; } if (/^(\d+\.\d+) KB$/) { push @busy, $1; next; } die "Bad line: $.: $_"; } # $state eq 'post' if (/^(\d+\.\d+) KB$/) { push @post, $1; next; } die "Bad line: $.: $_"; } my $time = 0; my $y; for (@pre) { $y = $_; print "$time,$y,,\n"; $time += 0.05; } print "$time,,$y,\n"; for (@busy) { $y = $_; print "$time,,$y,\n"; $time += 0.05; } print "$time,,,$y\n"; for $y (@post) { print "$time,,,$y\n"; $time += 0.05; }