- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2013-09-14 14:35 编辑
回复 1# oukm
modify from your code ...
$ wc MENU.FNT
1168463 3960509 58142720 MENU.FNT
$ time perl hex.pl
real 0m8.542s
user 0m4.032s
sys 0m3.216s
$ time perl hex1.pl # your code
real 0m17.034s
user 0m4.772s
sys 0m9.557s
$ cat hex.pl
use strict;
use warnings;
my $infile = "MENU.FNT";
my $outfile = "fontshow1.txt";
open(FHin, "<", $infile) || die "Can not open file $infile !";
open(FHout, ">", $outfile) || die "Can not open file $outfile !";
binmode FHin;
binmode FHout;
while(my $sLen = read(FHin, my $sBuf, 32*32*1024))
{
my $sTxt = unpack('H*', $sBuf);
my $sCycle = int($sLen /4 ) + ($sLen %4 != 0) -1;
my $sOut = "";
foreach(0 .. $sCycle){
$sOut .= substr($sTxt, $_*8, 8) . "\r\n";
}
print FHout "$sOut";
}
close(FHin);
close(FHout);
|
|