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);
}
阅读(2693) | 评论(0) | 转发(0) |