in reply to unpack in incrementing variables
As you said, use (s)printf. (printf doesnt respect -l so this looks a touch more clumsy than it needs to).
D:\dev>perl -e "printf '%08b%s',$_,$/ for 1..10" 00000001 00000010 00000011 00000100 00000101 00000110 00000111 00001000 00001001 00001010
Unpack operates on strings not on integers so you need to ensure that chr(10) is passed in and not '10'.
D:\dev>perl -le "print unpack 'B*',chr($_) for 1..10" 00000001 00000010 00000011 00000100 00000101 00000110 00000111 00001000 00001001 00001010
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: unpack in incrementing variables
by GrandFather (Saint) on Oct 14, 2005 at 09:38 UTC | |
by demerphq (Chancellor) on Oct 14, 2005 at 09:44 UTC | |
by GrandFather (Saint) on Oct 14, 2005 at 10:31 UTC | |
by Roy Johnson (Monsignor) on Oct 14, 2005 at 17:59 UTC |