Subject: | Text-Morse-0.01 - Decode("-----") fails due to 0 and bug relating to lack of defined() |
Date: | Thu, 20 Jul 2006 13:53:55 +0100 |
To: | bug-Text-Morse [...] rt.cpan.org |
From: | Kevin J Walters <kevin.walters [...] morganstanley.com> |
Hi,
diff shows the trivial fix, btw, is there a morse code for the
underscore (_) character?
prompt$ diff -c Morse-orig.pm Morse.pm
*** Morse-orig.pm Fri Jul 20 04:42:34 2001
--- Morse.pm Thu Jul 20 12:36:27 2006
***************
*** 103,109 ****
my ($self, @codes) = @_;
my @words = @codes;
my $dec = $self->{'dec'};
! my $sub = sub { $_ = $dec->{shift()}; $_ ? $_ : "<scrambled>"; };
foreach (@words) {
s/([\.-]+)\s*/&$sub($1)/ge;
}
--- 103,111 ----
my ($self, @codes) = @_;
my @words = @codes;
my $dec = $self->{'dec'};
! # my $sub = sub { $_ = $dec->{shift()}; $_ ? $_ : "<scrambled>"; };
! ### BUG BUG BUG - original was not using defined() do decode of ----- fails (it's 0)
! my $sub = sub { $_ = $dec->{shift()}; defined($_) ? $_ : "<scrambled>"; };
foreach (@words) {
s/([\.-]+)\s*/&$sub($1)/ge;
}
regards
|<evin
--
Kevin J Walters Morgan Stanley
kevin.walters@morganstanley.com 20 Cabot Square
Tel: 020 7425 7886 Canary Wharf
Fax: 020 7677 8504 London E14 4QW