请教程序匹配的问题,谢谢~
qinyu
|
1#
qinyu 发表于 2008-12-08 10:40
请教程序匹配的问题,谢谢~
请教程序匹配的问题,谢谢~
程序有几个匹配的报错,没看出来。请帮我看一下。######行是报错的地方。 这是文件command.txt |Store # |Speed |Direction |FIS Type |Description |Tag |Timestamp | |0 |3 Gbps |D->H |FIS 34 - Status: 0x50 - DRDY |LBA = 0x0000001 Sec Cnt = 0x01 | |5190788604 ns | |8 |3 Gbps |H->D |FIS 27 - Cmd: 0xEC=IDENTIFY DRIVE |LBA = 0x05AA501 Sec Cnt = 0x01 | |6679982484 ns | |20 |3 Gbps |H->D |FIS 27 - Cmd: 0xEF=SET FEATURES |LBA = 0x05AA501 Sec Cnt = 0x0C | |6681451468 ns | |28 |3 Gbps |D->H |FIS 34 - Status: 0x50 - DRDY |LBA = 0x05AA501 Sec Cnt = 0x0C | |6681579824 ns | |36 |3 Gbps |H->D |FIS 27 - Cmd: 0xEF=SET FEATURES |LBA = 0x05AA501 Sec Cnt = 0x45 | |6681714584 ns | |44 |3 Gbps |D->H |FIS 34 - Status: 0x50 - DRDY |LBA = 0x05AA501 Sec Cnt = 0x45 | |6681897132 ns | |52 |3 Gbps |H->D |FIS 27 - Cmd: 0xC6=SET MULTPLE MOD |LBA = 0x05AA501 Sec Cnt = 0x10 | |6681976448 ns | |60 |3 Gbps |D->H |FIS 34 - Status: 0x50 - DRDY |LBA = 0x0001001 Sec Cnt = 0x10 | |6682009284 ns | |68 |3 Gbps |H->D |FIS 27 - Cmd: 0xE3=IDLE |LBA = 0x0001001 Sec Cnt = 0x00 | |6682043412 ns | |76 |3 Gbps |D->H |FIS 34 - Status: 0x50 - DRDY |LBA = 0x0001001 Sec Cnt = 0x00 | |6682078204 ns | |84 |3 Gbps |H->D |FIS 27 - Cmd: 0xB0=SMART |LBA = 0x0C24F01 Sec Cnt = 0x00 | |6682118252 ns | |92 |3 Gbps |D->H |FIS 34 - Status: 0x50 - DRDY |LBA = 0x0C24F01 Sec Cnt = 0x00 | |6727610912 ns | |100 |3 Gbps |H->D |FIS 27 - Cmd: 0xF5=SECURITY FREEZE |LBA = 0x0C24F01 Sec Cnt = 0x00 | |7359313096 ns | |108 |3 Gbps |D->H |FIS 34 - Status: 0x50 - DRDY |LBA = 0x0C24F01 Sec Cnt = 0x00 | |7403747948 ns | |116 |3 Gbps |H->D |FIS 27 - Cmd: 0x25=READ DMA EXT |LBA = 0x000000000000 Sec Cnt = 0x0000 | |9118137956 ns | |126 |3 Gbps |D->H |FIS 34 - Status: 0x50 - DRDY |LBA = 0x0000000 Sec Cnt = 0x00 | |9133372960 ns | |134 |3 Gbps |H->D |FIS 27 - Cmd: 0x25=READ DMA EXT |LBA = 0x00000000003F Sec Cnt = 0x0000 | |9134984752 ns | |144 |3 Gbps |D->H |FIS 34 - Status: 0x50 - DRDY |LBA = 0x000003F Sec Cnt = 0x00 | |9135026884 ns | 这是程序: #!/usr/bin/perl open FH, "d:/command.txt" or die "$!"; open LOG,">d:/command_ide_sort.csv" or die "$!"; use strict; use warnings; my $format; find_format(); sub process_3 { print LOG "Start Time (ns),"; print LOG "Delta Time,"; print LOG "End Time,"; print LOG "Commands,"; print LOG "LBA,"; print LOG "Blocks\n"; my @start_time; my @delta_time; my @end_time; my @store; my @speed; my @direction; my @tag; my @command; my @LBA; my @block; my @timestamp; my @description; my @command_label; my @space; my $delta_time; my $store; my $speed; my $direction; my $tag; my $space; my $command; my $LBA; my $block; my $timestamp; my $description; my $command_label; my $end_time; my $start_time; my $time_label=0; while (my $line = <FH>) { # next unless ($line =~ /\|\d+\|/); # 跳过标题行 chomp($line); ($space,$store, $speed, $direction, $command, $description,$tag,$timestamp,) = split(/\s+\|/, $line); push @space, $space; push @store, $store; push @speed, $speed; push @direction, $direction; push @command, $command; push @description, $description; push @tag, $tag; push @timestamp, $timestamp; # print "$store "; # print "$command\n"; ######################################## if ($command=~/FIS (\d+) - Cmd: 0x([0-9A-Z]+)=(.*)/) { $command_label=$3; if ($command_label=~/WRITE|READ/) { $time_label=1; $command=$command_label; if ($timestamp=~/(\d+)\sns/) { $timestamp=$1; $start_time=$timestamp; } if ($description=~/LBA = 0x(.*)\s+Sec Cnt = 0x(.*)/) { $LBA=hex($2); $block=hex($2); } print LOG "$command "; print LOG "$LBA "; print LOG "$block "; } else {$time_label=0;} } if ( $time_label==1) { if ($command=~/FIS 34 - Status: 0x/) { ################################ if ($timestamp=~/(\d+)\sns/) { $timestamp=$1; $end_time=$timestamp; # print "$end_time "; } $delta_time=$end_time-$start_time; print LOG "$start_time "; print LOG "$delta_time "; print LOG "$end_time\n"; } } } } sub find_format { my @line; my $line; my @seconds; my @primitive; my @delta; my @end_time; my @ctype; my @counttype; my @summary; my @commands; my @LBA; my @Blocks; my $seconds; my $primitive; my $delta; my $end_time; my $ctype; my $counttype; my $summary; my $commands; my $LBA; my $Blocks; my $i; $line = <FH>; if ($line=~/Marks\s+Store\s+#\s+Event\s+Register\s+Data\s+Hi\s+Data\s+Lo\s+Description\s+Timestamp/) ################################ { $format=0; } elsif ($line=~/Marks\s+Store\s+#\s+Command\s+Drive\s+LBA\/CHS\s+Block\s+Count\s+Error\s+Timestamp/) ################################### { $format=1; } elsif ($line=~/\s+\|Store\s+#\s+\|FIS Type\s+\|Src ID\s+\|Description\s+\|Tag\s+\|Timestamp\s+\|/) ####################################### { $format=2; } elsif ($line=~/\s+\|Store\s+#\s+\|Speed\s+|Direction\s+|FIS Type\s+\|Description\s+\|Tag\s+\|Timestamp\s+\|/) { $format=3; process_3(); } elsif ($line=~/LBA.CHS/) { $format=4; } elsif ($line=~/\s+\|Store\s+#\s+\|Timestamp\s+\|Speed\s+|Direction\s+|FIS Type\s+\|Description\s+\|Tag\s+\|/) { $format=5; } elsif ($line=~/TimeTick OP FE LBA Cnt DC Sec Cyl DH/) { # Data logger drive format $format=6; } elsif ($line=~/Channels/) { $format=7; # get_index_7_format(); } } find_format(); { if ($format==0) {process_0();print "0";} if ($format==1) {process_1();print "1";} if ($format==2) {process_2();print "2";} if ($format==3) {process_3();print "3";} if ($format==4) {process_4();print "4";} if ($format==5) {process_5();print "5";} if ($format==6) {process_6();print "6";} if ($format==7) {process_7();print "7";} }
|