in reply to Efficient 7bit compression
use strict; use warnings; my $str = 'abcdefghijklmnop'; sub shrink { my $bitstr = unpack('B*', $_[0]); $bitstr =~ s/.(.{7})/$1/g; pack('B*', $bitstr); } sub grow { my $bitstr = unpack('B*', $_[0]); $bitstr =~ s/(.{7})/0$1/g; pack('B*', $bitstr); } my $shrunk = shrink($str); printf "Was: %s, Is: %s\n", length($str), length($shrunk); printf "Restored: <%s>\n", grow $shrunk;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Efficient 7bit compression
by Limbic~Region (Chancellor) on Mar 14, 2005 at 15:52 UTC | |
by Roy Johnson (Monsignor) on Mar 14, 2005 at 16:05 UTC | |
by Limbic~Region (Chancellor) on Mar 14, 2005 at 16:14 UTC | |
by Roy Johnson (Monsignor) on Mar 14, 2005 at 16:36 UTC | |
by Limbic~Region (Chancellor) on Mar 14, 2005 at 16:43 UTC | |
| |
by Ven'Tatsu (Deacon) on Mar 14, 2005 at 19:43 UTC | |
by Roy Johnson (Monsignor) on Mar 14, 2005 at 20:22 UTC |