1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#!/usr/bin/perl -ws
# Search through the archives splitting out stuff that has pathnames.
while (1) {
&headers;
&body;
}
sub headers
{
while (<>) {
warn "HDR $_" if ($debug);
return if /^\s*$/;
}
exit;
}
# Save the info for the system, skipping everything ig there is no info.
sub body
{
@info = ();
while (<>) {
last if m|^[-]+ \.\./results|;
last if /^\[lmbench/;
if (/^From[: ]/) { warn "FROM $_"; return; }
warn "INFO $_" if ($debug);
push(@info, $_);
}
if (/^[-]+ \.\.\/results/) {
@foo = split;
$path = $foo[1];
$path =~ s|\.\./||;
warn "PATH $path\n" if ($debug);
&results;
return;
}
warn "SKIPPING one\n";
while (<>) {
warn "SKIP $_" if ($SKIP);
last if /^Memory load latency/;
if (/^From[: ]/) { warn "FROM $_"; return; }
}
die "No memory load latency" unless /^Memory load latency/;
while (<>) {
warn "SKIP $_" if ($SKIP);
last if /^\[/;
if (/^From[: ]/) { warn "FROM $_"; return; }
}
die "No date" unless /^\[/;
while (<>) {
last unless /^\s*$/;
if (/^From[: ]/) { warn "FROM $_"; return; }
}
}
sub results
{
@results = ();
while (<>) {
goto done if (/^From[: ]/);
warn "RES $_" if ($RES);
push(@results, $_);
last if /^Memory load latency/;
}
die "No memory load latency" unless /^Memory load latency/;
while (<>) {
goto done if (/^From[: ]/);
warn "RES $_" if ($RES);
push(@results, $_);
last if /^\[/;
}
die "No date" unless /^\[/;
while (<>) {
last unless /^\s*$/;
}
done:
($dir = $path) =~ s|/[^/]+$||;
warn "DIR $dir\n" if ($debug);
system "mkdir -p $dir";
if (-e $path) {
warn "CONFLICT on $path\n" if $debug;
for ($i = 0; ; $i++) {
$tmp = "${path}.${i}";
last if ! -e $tmp;
warn "CONFLICT on $tmp\n" if $debug;
}
$path = $tmp;
}
$info = $path . ".INFO";
open(O, ">$info");
print O @info;
close(O);
warn "Saving $path\n" if $verbose;
open(O, ">$path");
print O @results;
close(O);
}
|