- or download this
sub packwithsubst {
my $string = shift;
my $bits = unpack 'b*', $string;
...
substr $chars, $length * 8, 8, '';
return pack 'b*', $chars;
}
- or download this
Rate GSM::SMS
GSM::SMS 324/s --
Device::Gsm 342/s 6%
My_code 514/s 59%
- or download this
my (%b2c, %c2b);
$b2c{unpack 'b8', $_} = $_ for map chr, 0..255;
$c2b{$_} = unpack 'b7', $_ for map chr, 0..127;
...
$decoded .= pack 'b7', substr $bits, 0, 7, '' while length $bits >
+= 7;
return substr $decoded, 0, $len;
}
- or download this
Rate GSM::SMS
GSM::SMS 322/s --
Device::Gsm 345/s 7%
My_code 519/s 61%
Dev::Gsm_opt 519/s 61%
- or download this
sub packwitharray {
my $string = shift;
return pack 'Cb*', length($string), join('', unpack '(b7)*', $stri
+ng);
...
$#chars = $length - 1;
return pack '(b7)*', @chars;
}
- or download this
Rate GSM::SMS
GSM::SMS 321/s --
Device::Gsm 342/s 7%
...
Subst/Array 527/s 64% # i.e. packwithsubst / unpackwitharray
Array/Subst 777/s 142%
Array/Array 808/s 152%
- or download this
Rate My_code C
My_code 792/s -- -99%
C 77422/s 9670% --
- or download this
#! /usr/bin/perl
use strict;
...
free(unpacked);
return rv;
}