in reply to Re: Re: Re: Re: Why does it return 0?
in thread Why does it return 0?

%b formats a number as binary (but first casts it to an unsigned value, so you'd need to make sure you only feed it positive values):
$ perl -we'printf "%b", 123' 1111011
(printf outputs directly, sprintf returns a formatted string).

Looks like your code above will give undef for 0; I think that could be fixed by changing your while () {} do a do {} while ().