On Mon, Aug 18, 2003 at 07:34:41AM -0400 Kipp, James wrote:

> > I have a file cointaing 1024  hex  numbers .
> > I want to convert them to Bin.
> > Please help
> 
> try something like this:
> 
> $hex = 0xff;
> $bin = unpack("B32", pack("N", hex $hex));

The above assumes big-endian byteorder. For little-endian use "V" instead
of "N". Or just use "L" when the file has the same byteorder as the
machine you are running this script on.

Btw, the hex() above is probably wrong. hex() converts a string into a
numeric value by intepreting it as hexadecimal. Essentially, you do it
twice resulting in:

    $hex = 0xff == 255 => hex(255) == 597

Whereas:

    $hex = "0xff" => hex($hex) == 255
    
Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to