in reply to Best way to represent somewhat large values in a module
You say you are converting to hex but then go on to say And using pack and unpack makes them unprintable, which is annoying.
Why not just treat them as strings (these will typically be unprintable) and upack them into hex as requrired for printable output. You can use bitmap operators on strings (with care)
my $num = "\000\001\002\003\004\005\006\007\010\011\012\013"; my ($bin) = unpack "B*", $num; print length $bin, ": ", $bin, "\n"; print printable($num), "\n"; $num |= "\000\001\002\003\004\005\006\007\010\377\012\013"; print printable($num), "\n"; sub printable { unpack "H*", $_[0] }
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best way to represent somewhat large values in a module
by sgifford (Prior) on Jun 19, 2004 at 10:11 UTC | |
by tachyon (Chancellor) on Jun 19, 2004 at 10:16 UTC |