in reply to Why does it return 0?
From the Perl Cookbook:
sub dec2bin { my $str = unpack("B32", pack("N", shift)); $str =~ s/^0+(?=\d)//; # otherwise you'll get leading zeros return $str; } sub bin2dec { return unpack("N", pack("B32", substr("0" x 32 . shift, -32))); }
And your code is always returning zero because you declare $binnumb inside of the subroutine, thus resetting it every time it is called. At the last execution of the routine, $inNumb % 2 is zero.
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Why does it return 0?
by mAineAc (Novice) on Feb 05, 2004 at 02:13 UTC | |
by bart (Canon) on Feb 05, 2004 at 12:03 UTC |