pack problem?

D

Davy

Hi all,

I want to write a dec data to bin data translator.
But I found the $dec_pack in the program don't print "A signed integer
value" as the pack manual said. Why? Thanks!

#------------------------------------------------
use strict;
use warnings;


my $dec = 1234;
my $bin;

$bin = dec2bin($dec);

print 'bin is ',$bin,"\n";

sub dec2bin {
my $dec_shift = shift;
print 'dec_shift is ',$dec_shift, "\n";

my $dec_pack = pack("i", $dec_shift);
print 'dec_pack ',$dec_pack, "\n";

return unpack('B32', $dec_pack);
}
#----------------------------------------------------

Best regards,
Davy
 
P

Peter J. Holzer

["Followup-To:" header set to comp.lang.perl.misc.]
I want to write a dec data to bin data translator.
But I found the $dec_pack in the program don't print "A signed integer
value" as the pack manual said. Why? Thanks!

Why do you think so?

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top