rendered paste body#!/usr/bin/perl
# oscar.pl
use strict;
$|=1;
my ($line, $word, $size, $ok, $failed, $file, $input);
my @words;
my $dir = $ARGV[0];
print "Analyzing files in: $dir\n";
open(OUT, "> analyze.txt");
opendir(DIR, "$dir");
while (defined($file = readdir(DIR))) {
next if $file =~ /^\.\.?$/;
$input = $dir . $file . "/classcycle-full.txt";
open(IN, "< $input");
$ok=0;
$failed=0;
while (<IN>) {
my $line = $_;
$line =~ s/\n//g;
@words =split(/\s+/, $line);
if ($words[@words-1] =~ /OK/) {
$ok++;
}
elsif ($words[@words-1] =~ /failed/) {
$failed++;
}
}
print OUT substr($file, 0, length($file)-4) . " $ok, $failed\n";
}
print "Writing data to: analyze.txt\n";
close(DIR);