this function works only for 32 bits,
this will work for any binary length
sub b2h {
my $num=shift;
my $WIDTH=32;
my $index=length($num)-$WIDTH;
print "index= $index\n";
my $hex="";
do {
my $width=$WIDTH;
if ($index<0) {
$width+=$index;
$index=0;
}
$cut_string=substr($num,$index,$width);
print "index is $index width is $width Cut String is $cut_string\n";
$hex= sprintf('%X', oct("0b$cut_string")). $hex;
$index-=$WIDTH;
} while ($index>(-1*$WIDTH));
return $hex;
}