use strict;
use warnings;
-use Carp qw/croak/;
-use Encode qw/decode_utf8/;
-use Storable qw/thaw/;
+use Carp qw<croak>;
+use Encode qw<decode_utf8>;
+use Storable qw<thaw>;
-use Bit::MorseSignals qw/:consts/;
+use Bit::MorseSignals qw<:consts>;
=head1 NAME
=head1 VERSION
-Version 0.04
+Version 0.07
=cut
-our $VERSION = '0.04';
+our $VERSION = '0.07';
=head1 SYNOPSIS
use Bit::MorseSignals::Receiver;
- my $pants = new Bit::MorseSignals::Receiver done => sub { print "received $_[1]!\n" };
+ my $pants = Bit::MorseSignals::Receiver->new(done => sub { print "received $_[1]!\n" });
while (...) {
my $bit = comes_from_somewhere_lets_say_signals();
$pants->push($bit);
sub new {
my $class = shift;
- $class = ref $class || $class || return;
+ return unless $class = ref $class || $class;
croak 'Optional arguments must be passed as key => value pairs' if @_ % 2;
my %opts = @_;
my $self = {
# BM_DATA_{PLAIN, UTF8, STORABLE}
$self->{msg} = defined $demanglers[$self->{type}]
? do {
- my $msg = eval {
- $demanglers[$self->{type}]->($self->{buf})
- };
- $@ ? undef : $msg;
+ local $SIG{__DIE__} = sub { warn @_ };
+ $demanglers[$self->{type}]->($self->{buf})
}
: $self->{buf};
$self->reset;
vec($self->{buf}, $self->{len}++, 1) = $bit;
if ($self->{len} >= 3) {
- my $type = 2 * vec($self->{buf}, 0, 1)
- + vec($self->{buf}, 1, 1);
+ my $type = 2 * vec($self->{buf}, 1, 1)
+ + vec($self->{buf}, 0, 1);
$type = BM_DATA_PLAIN if vec($self->{buf}, 2, 1);
- @{$self}{qw/state type buf len/} = (3, $type, '', 0);
+ @{$self}{qw<state type buf len>} = (3, $type, '', 0);
}
} elsif ($self->{state} == 1) { # end of signature
} else { # first bit
- @{$self}{qw/state sig sig_bit sig_len buf len/}
+ @{$self}{qw<state sig sig_bit sig_len buf len>}
= (1, '', $bit, 1, '', 0 );
vec($self->{sig}, 0, 1) = $bit;
my ($self) = @_;
_check_self($self);
$self->{state} = 0;
- @{$self}{qw/sig sig_bit sig_len type buf len/} = ();
+ @{$self}{qw<sig sig_bit sig_len type buf len>} = ();
return $self;
}
Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
-You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince).
+You can contact me by mail or on C<irc.perl.org> (vincent).
=head1 BUGS
perldoc Bit::MorseSignals::Receiver
+Tests code coverage report is available at L<http://www.profvince.com/perl/cover/Bit-MorseSignals>.
+
=head1 COPYRIGHT & LICENSE
Copyright 2008 Vincent Pit, all rights reserved.