2chとかにはってある HDD Bench の結果を成形してmycpuとかmyvideoのデーターとして成形するソート付き

# -_-* perl *-_-
use strict;
use utf8;
use Data::Dumper;

$| = 1;

my @lines = ();
my @datas = ();

while(<>)
{
	chomp; s/^ +//; s/ +$//;
	next if( /^$/ );
	
	push @lines, $_;
}

my %bak;

while(@lines)
{
	$_ = shift @lines;

	if( /HDBENCH Ver 3/ )
	{
		my @bak = @lines;
		my %topic;
		&HDBENCH3406(\%topic);
		push @datas,\%topic;
		@lines = @bak;
	}
}

# print Dumper [\@datas];

print <<__TEXT;

====================
===  MYCPU.TXT  ====
====================
__TEXT
foreach( sort {
     $$b{Integer} + $$b{Float}
 <=> $$a{Integer} + $$a{Float} } @datas )
{
	next unless( $$_{Integer} );
	next unless( $$_{Float} );
	
	next unless( $$_{Integer} =~ /\d+/ );
	next unless( $$_{Float} =~ /\d+/ );
	
	next if ( $$_{Processor} eq $bak{Processor} 
	     and  $$_{Integer}   eq $bak{Integer} 
	     and  $$_{Float}     eq $bak{Float}   );
	     
	print "$$_{Processor}\n";
	print "$$_{Integer}\n";
	print "$$_{Float}\n";

	%bak = %$_;
}


	%bak = ();
print <<__TEXT;

====================
===  MYVIDEO.TXT  ====
====================
__TEXT
foreach( sort { 
     $$b{Rectangle} + $$b{Text} + $$b{Ellipse} + $$b{BitBlt}
 <=> $$a{Rectangle} + $$a{Text} + $$a{Ellipse} + $$a{BitBlt} } @datas )
{
	next unless( $$_{Rectangle} );
	next unless( $$_{Text} );
	next unless( $$_{Ellipse} );
	next unless( $$_{BitBlt} );
	
	next unless( $$_{Rectangle} =~ /\d+/ );
	next unless( $$_{Text} =~ /\d+/ );
	next unless( $$_{Ellipse} =~ /\d+/ );
	next unless( $$_{BitBlt} =~ /\d+/ );
	
	next if ( $$_{VideoCard} eq $bak{VideoCard} 
	     and  $$_{Processor} eq $bak{Processor} 
	     and  $$_{Rectangle} eq $bak{Rectangle} 
	     and  $$_{Text}      eq $bak{Text}      
	     and  $$_{Ellipse}   eq $bak{Ellipse}   
	     and  $$_{BitBlt}    eq $bak{BitBlt}    );

	print "$$_{VideoCard}\n";
	print "$$_{Processor}\n";
	print "$$_{Rectangle}\n";
	print "$$_{Text}\n";
	print "$$_{Ellipse}\n";
	print "$$_{BitBlt}\n";
	%bak = %$_;
}

sub HDBENCH3406
{
	my $data = shift;
	my @topic = ( 'M/B Name', 'Processor', 'VideoCard', 'Resolution', 'Memory', 'OS', 'Date' );
	my @key1 = qw/ ALL  Integer   Float  MemoryR MemoryW MemoryRW  DirectDraw /;
	my @key2 = qw/ Rectangle   Text Ellipse  BitBlt    Read   Write   RRead  RWrite  Drive /;

	while(@lines)
	{
		$_ = shift @lines;
		next if( /^$/ );
		
		foreach my $topic( @topic )
		{
		#	print "$topic : $'\n" 
			if ( /^$topic\s+/x )
			{
	#			warn "$topic : $$data{$topic} to $'\n" if( $$data{$topic} and $$data{$topic} ne $' );
				$$data{$topic} = $';
				next;
			}
		}
	# 
	#	print "$_\n";
		my @col = split(/\s+/, $_);
		
		my @diff = grep { !{map{$_,1}@key1 }-> {$_}}@col;
		unless( @diff )
		{
			val(\@key1, $data);
			;
		}

		my @diff = grep { !{map{$_,1}@key2 }-> {$_}}@col;
		unless( @diff )
		{
			val(\@key2, $data);
			last;
		}

	}
	
	return;
}

sub val
{
	my $key = shift;
	my $topic = shift;
	
	while(@lines)
	{
		$_ = shift @lines;
		chomp; s/^ +//; s/ +$//;
		my @col = split(/\s+/, $_);
		
		my $i = 0;
		foreach( @col )
		{
		#	print $$key[$i], "#" , $_, "\n";
			$$topic{$$key[$i]} = $_;
			$i++;
		}
		
		last;
	}
}



Resolution 1280x1024 (32Bit color) とかぐぐって
http://pc11.2ch.net/test/read.cgi/hard/991465771/ とかを
hoge.txt にCTRL+A テキストで保存

perl hdbench.pl hoge.txt