1
我想将位于$ 1,$ 2,$ 3和$ 4中的十六进制值转换为二进制文件并保存到数组中。我知道$ 1只是一个字符串,所以我想将它转换转换为二进制之前诅咒,但它不工作...这里是我的代码:在Perl中将十六进制转换为二进制文件
#! usr/bin/perl
use warnings;
use strict;
while(<>)
{
if(/SIB_DBG/)
{
if(/TTRB:\s*([\da-f]+)\s([\da-f]+)\s([\da-f]+)\s([\da-f]+)/ ||
/ETRB:\s*([\da-f]+)\s([\da-f]+)\s([\da-f]+)\s([\da-f]+)/ ||
/Command\sETRB\s*([\da-f]+)\s([\da-f]+)\s([\da-f]+)\s([\da-f]+)/)
{
my $one = $1;
my $two = $2;
my $three = $3;
my $four = $4;
print "$_ $one $two $three $four\n";
printf("binary :%b\n",$four);
}
}
}
我输入日志文件就像
Aug 31 15:25:53 usb3 kernel: [ 78.812034] SIB_DBG TTRB:01000680 00080000 00000008 00030840, PTR: ffff88005ff8b800
Aug 31 15:25:53 usb3 kernel: [ 78.815428] SIB_DBG ETRB: 5ff8b850 00000000 01000000 01018001
而且我得到一个错误,在某些行说..
争论 “f8891” 是不是在printf的数字在script.plx线21,<>行6.