Acme-Morse-Audible
view release on metacpan or search on metacpan
our $VERSION = '1.10';
my $hearable = "\x4d\x54\x68\x64\0\0\0\6\0\0\0\1\x60\0\115\124\162\153";
my($long,$short)=("\xFF\x40\x90\x56\x50\x82\xDF\0\x80\x56\x00","\xFF\x40\x90\x56\x50\xFF\x40\x80\x56\x00");
sub record{
local $_ = unpack 'b*', pop;
s/(.)/$1?$long:$short/eg;
$_="\0\xC0\x11\0\xFF\x59\x02\0\0$_\0\xFF\x2F";
$hearable . pack('L', length($_)) . $_;
}
sub play{
local $_ = pop;
chomp;
s/^$hearable.{4}.+?\0{2}//;s/\0\xFF\x2F$//;
s/\xFF\x40(.+?)\x56\0/length($1)==7?1:0/ge;
pack 'b*', $_;
}
open 0 or die "Cannot hear '$0'.\n";
(my $telegram = do{local $/=undef;<0>}) =~ s/.*^\s*(use|no)\s+Acme::Morse::Audible\s*;\n//sm;
close 0;
if($1 eq 'use'){
if($telegram =~ /^$hearable/){
eval play $telegram;
( run in 0.631 second using v1.01-cache-2.11-cpan-65fba6d93b7 )