请教程序匹配的问题,谢谢~

请教程序匹配的问题,谢谢~

请教程序匹配的问题,谢谢~
程序有几个匹配的报错,没看出来。请帮我看一下。######行是报错的地方。
这是文件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";}
}




   

表达式中 的 '-' 需要 用 .
表达式中 的 '-' 需要 用 '\-'表示
改后仍然有错
改过后或者改成 if ($command=~/FIS (\d+).*Cmd: 0x([0-9A-Z]+)=(.*)/) {
都不行的。
怎么能纠正输出中的错误?
输出中最后一行多余,即重复的标题行。
store #, Commands,LBA,Blocks,Start Time (s),Delta Time (ms),End Time (s)
116, READ DMA EXT, 0, 0, 9.118137956, 15.2350040000009, 9.13337296
134, READ DMA EXT, 0, 0, 9.134984752, 0.0421319999990288, 9.135026884
.......................................................
427402, WRITE DMA EXT, 0, 0, 242.272102916, 0.036339999979873, 242.272139256
store #, Commands,LBA,Blocks,Start Time (s),Delta Time (ms),End Time (s)
[quote]--/FIS\s+(\d+)\.

/FIS\s+(\d+).+?0x([\dA-F]+)=([\w\s]+)/



/(\d+).+?0x([\dA-F]+)=([\w\s]+)/




   

DOS中运行该程序,请问该怎样改?
将上面我的程序的前六行改成下面的,目的是在DOS中运行该程序,请问该怎样改?


use strict;
use warnings;

my $format; my $file_name; my $out_file;

command_line_parser();

open_data_file();

find_format();





############################################################################

sub command_line_parser
{
     $_=$#ARGV;

     foreach $_ (@ARGV)
     {
        print "ppp" ;
          if (/file=/i)     # file option
          {
               $file_name=$';  print "$file_name";
            $out_file=$file_name;
          }

          if (/-h/i)          # help option
          {
               usage();
          }
     }

     if (!$file_name)     # if 'file=' option not found, then inform user of how to run porgram
     {
          usage();
     }
}

############################################################################

sub usage
{

     print "\nUsage:\n\n";
     print "  findformat.pl <file=file_name> <-v> <-h>\n\n";
     print "  <file> path and name of file to process\n";
    #     print "   <-v> option displays program version number information\n";
    #     print "   <-h> option displays this help message\n\n";
     print "This program will parse a raw Data Transfer Bus Doctor trace and generate\n";
     print "sorted output files that can be used by the 'stat'pl' program.\n\n";
#     print "To process a raw SCSI trace one would run 'ide_sort.pl file=filename.txt'\n";
#     print "To process an IDE trace, one would run 'ide_sort.pl file=filename.csv\n\n";
#     print "Output files created will be either *_scsi_sort.txt or *_ide_sort.txt\n\n";


     exit;
}

############################################################################

sub open_data_file
{

  open FH, $file_name or die "$!";
# open LOG, $out_file or die "$!";
 open LOG,">d:/$out_file._ide_sort.txt" or die "$!";
#  open FILE, $file_name or die $!;

  print "Parsing raw traces $file_name\n";

}