文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>perl 对二进制文件的操作

perl 对二进制文件的操作

时间:2010-08-09  来源:rrgela

sub ChangeByte { my $file=shift(); my $Byte=shift(); my $value=shift(); open(FH,"+<$file") or die "File not exist \n"; binmode FH; seek (FH,$Byte,0); print (FH pack("H*",$value)); close(FH); }
sub ChangeBit { my $file=shift(); my $Byte=shift(); my $Bit=shift(); #my $value1=shift(); 
open(FH,"+<$file") or die "File not exist \n"; binmode FH; my $charb; seek (FH,$Byte,0); read(FH,$charb,1); my $Bit2; $Bit2=7-$Bit; ($charb)=unpack("B*",$charb);        #print "the Byte is $charb"; my $chara=substr($charb,0,$Bit2); my $value=substr($charb,$Bit2,1); my $value1;   if ($value eq "1") { $value1="0"; } else { $value1="1"; } my $charc=substr($charb,$Bit2+1,$Bit); $charb=$chara.$value1.$charc;   seek (FH,$Byte,0); print (FH pack("B*",$charb)); close(FH); }
相关阅读 更多 +
排行榜 更多 +
瓢虫少女

瓢虫少女

飞行射击 下载
潜艇鱼雷

潜艇鱼雷

飞行射击 下载
网络掠夺者

网络掠夺者

飞行射击 下载