从log 截取1/ 3 字段(已空格隔开)写入excel

cat file.txt

1 2 3

1 2 3

1 2 3

截取1 和3 字段,然后写入excel

#!/tools/cfr/bin/perl -w

use Spreadsheet::WriteExcel;

my @args="";

open IN, "/home/zhangbo/perl/auto_tools" or die "Can't open the input file ! \n";

 

my $workbook = Spreadsheet::WriteExcel->new("auto_tools.xls");

my $worksheet = $workbook->add_worksheet();

#$worksheet->add_write_handler(qr[\w], \&store_string_widths);

#Add head to worksheet

my $heading = $workbook->add_format(align => 'center', bold => 1);

        $worksheet->write(0, 0, "Cell Name", $heading);

        $worksheet->write(0, 1, "Parameters", $heading);

        $worksheet->write(0, 2, "value",  $heading);

 

$i=1;

while (<IN>){

my @args=split;

print "$args[0]\n";

$colum_1=0;

$colum_2=1;

$worksheet->write($i,$colum_1, $args[0]);

$worksheet->write($i,$colum_2, $args[2]);

$i=$i+1;

}

close IN;

你可能感兴趣的:(3,截取1/,从log)