|
|
发表于 2012-9-4 16:58:20
|
显示全部楼层
本帖最后由 songzijian87 于 2012-9-4 17:03 编辑
回复 10# lyz5432
大神啊,把小骆驼书看得这么熟,正解
不过稍微修改一下更好
open BINARY_IN,"<binary.txt" or die "can not open file binary.txt:$!";
open DECIMAL_OUT,">decimal.txt" or die "can not create file decimal.txt:$!";
while (<BINARY_IN>)
{
my @binary_strings = split;
foreach my $a (@binary_strings)
{
printf DECIMAL_OUT "%d\n ",oct('0b'.$a);
}
}
close BINARY_IN;
close DECIMAL_OUT; |
|
|